• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Qiskit / qiskit / 11105676556

30 Sep 2024 12:03PM CUT coverage: 88.873% (+0.006%) from 88.867%
11105676556

Pull #13210

github

web-flow
Bump pypa/cibuildwheel in the github_actions group across 1 directory

Bumps the github_actions group with 1 update in the / directory: [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel).


Updates `pypa/cibuildwheel` from 2.19.2 to 2.21.1
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.19.2...v2.21.1)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github_actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #13210: Bump pypa/cibuildwheel from 2.19.2 to 2.21.1 in the github_actions group across 1 directory

74130 of 83411 relevant lines covered (88.87%)

377705.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/crates/circuit/src/dot_utils.rs
1
// This code is part of Qiskit.
2
//
3
// (C) Copyright IBM 2022
4
//
5
// This code is licensed under the Apache License, Version 2.0. You may
6
// obtain a copy of this license in the LICENSE.txt file in the root directory
7
// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
//
9
// Any modifications or derivative works of this code must retain this
10
// copyright notice, and modified files need to carry a notice indicating
11
// that they have been altered from the originals.
12

13
// This module is forked from rustworkx at:
14
// https://github.com/Qiskit/rustworkx/blob/c4256daf96fc3c08c392450ed33bc0987cdb15ff/src/dot_utils.rs
15
// and has been modified to generate a dot file from a Rust DAGCircuit instead
16
// of a rustworkx PyGraph object
17

18
use std::collections::BTreeMap;
19
use std::io::prelude::*;
20

21
use crate::dag_circuit::{DAGCircuit, Wire};
22
use pyo3::prelude::*;
23
use rustworkx_core::petgraph::visit::{
24
    EdgeRef, IntoEdgeReferences, IntoNodeReferences, NodeIndexable, NodeRef,
25
};
26

27
static TYPE: [&str; 2] = ["graph", "digraph"];
28
static EDGE: [&str; 2] = ["--", "->"];
29

30
pub fn build_dot<T>(
×
31
    py: Python,
×
32
    dag: &DAGCircuit,
×
33
    file: &mut T,
×
34
    graph_attrs: Option<BTreeMap<String, String>>,
×
35
    node_attrs: Option<PyObject>,
×
36
    edge_attrs: Option<PyObject>,
×
37
) -> PyResult<()>
×
38
where
×
39
    T: Write,
×
40
{
×
41
    let graph = dag.dag();
×
42
    writeln!(file, "{} {{", TYPE[graph.is_directed() as usize])?;
×
43
    if let Some(graph_attr_map) = graph_attrs {
×
44
        for (key, value) in graph_attr_map.iter() {
×
45
            writeln!(file, "{}={} ;", key, value)?;
×
46
        }
47
    }
×
48

49
    for node in graph.node_references() {
×
50
        let node_weight = dag.get_node(py, node.id())?;
×
51
        writeln!(
×
52
            file,
×
53
            "{} {};",
×
54
            graph.to_index(node.id()),
×
55
            attr_map_to_string(py, node_attrs.as_ref(), node_weight)?
×
56
        )?;
×
57
    }
58
    for edge in graph.edge_references() {
×
59
        let edge_weight = match edge.weight() {
×
60
            Wire::Qubit(qubit) => dag.qubits().get(*qubit).unwrap(),
×
61
            Wire::Clbit(clbit) => dag.clbits().get(*clbit).unwrap(),
×
62
            Wire::Var(var) => var,
×
63
        };
64
        writeln!(
×
65
            file,
×
66
            "{} {} {} {};",
×
67
            graph.to_index(edge.source()),
×
68
            EDGE[graph.is_directed() as usize],
×
69
            graph.to_index(edge.target()),
×
70
            attr_map_to_string(py, edge_attrs.as_ref(), edge_weight)?
×
71
        )?;
×
72
    }
73
    writeln!(file, "}}")?;
×
74
    Ok(())
×
75
}
×
76

77
static ATTRS_TO_ESCAPE: [&str; 2] = ["label", "tooltip"];
78

79
/// Convert an attr map to an output string
80
fn attr_map_to_string<T: ToPyObject>(
×
81
    py: Python,
×
82
    attrs: Option<&PyObject>,
×
83
    weight: T,
×
84
) -> PyResult<String> {
×
85
    if attrs.is_none() {
×
86
        return Ok("".to_string());
×
87
    }
×
88
    let attr_callable = |node: T| -> PyResult<BTreeMap<String, String>> {
×
89
        let res = attrs.unwrap().call1(py, (node.to_object(py),))?;
×
90
        res.extract(py)
×
91
    };
×
92

93
    let attrs = attr_callable(weight)?;
×
94
    if attrs.is_empty() {
×
95
        return Ok("".to_string());
×
96
    }
×
97
    let attr_string = attrs
×
98
        .iter()
×
99
        .map(|(key, value)| {
×
100
            if ATTRS_TO_ESCAPE.contains(&key.as_str()) {
×
101
                format!("{}=\"{}\"", key, value)
×
102
            } else {
103
                format!("{}={}", key, value)
×
104
            }
105
        })
×
106
        .collect::<Vec<String>>()
×
107
        .join(", ");
×
108
    Ok(format!("[{}]", attr_string))
×
109
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc