diff --git a/crates/accelerate/src/commutation_analysis.rs b/crates/accelerate/src/commutation_analysis.rs new file mode 100644 index 000000000000..08fa1dda5ec9 --- /dev/null +++ b/crates/accelerate/src/commutation_analysis.rs @@ -0,0 +1,192 @@ +// This code is part of Qiskit. +// +// (C) Copyright IBM 2024 +// +// This code is licensed under the Apache License, Version 2.0. You may +// obtain a copy of this license in the LICENSE.txt file in the root directory +// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +// +// Any modifications or derivative works of this code must retain this +// copyright notice, and modified files need to carry a notice indicating +// that they have been altered from the originals. + +use pyo3::exceptions::PyValueError; +use pyo3::prelude::PyModule; +use pyo3::{pyfunction, pymodule, wrap_pyfunction, Bound, PyResult, Python}; +use qiskit_circuit::Qubit; + +use crate::commutation_checker::CommutationChecker; +use hashbrown::HashMap; +use pyo3::prelude::*; + +use pyo3::types::{PyDict, PyList}; +use qiskit_circuit::dag_circuit::{DAGCircuit, NodeType, Wire}; +use rustworkx_core::petgraph::stable_graph::NodeIndex; + +// Custom types to store the commutation sets and node indices, +// see the docstring below for more information. +type CommutationSet = HashMap>>; +type NodeIndices = HashMap<(NodeIndex, Wire), usize>; + +// the maximum number of qubits we check commutativity for +const MAX_NUM_QUBITS: u32 = 3; + +/// Compute the commutation sets for a given DAG. +/// +/// We return two HashMaps: +/// * {wire: commutation_sets}: For each wire, we keep a vector of index sets, where each index +/// set contains mutually commuting nodes. Note that these include the input and output nodes +/// which do not commute with anything. +/// * {(node, wire): index}: For each (node, wire) pair we store the index indicating in which +/// commutation set the node appears on a given wire. +/// +/// For example, if we have a circuit +/// +/// |0> -- X -- SX -- Z (out) +/// 0 2 3 4 1 <-- node indices including input (0) and output (1) nodes +/// +/// Then we would have +/// +/// commutation_set = {0: [[0], [2, 3], [4], [1]]} +/// node_indices = {(0, 0): 0, (1, 0): 3, (2, 0): 1, (3, 0): 1, (4, 0): 2} +/// +fn analyze_commutations_inner( + py: Python, + dag: &mut DAGCircuit, + commutation_checker: &mut CommutationChecker, +) -> PyResult<(CommutationSet, NodeIndices)> { + let mut commutation_set: CommutationSet = HashMap::new(); + let mut node_indices: NodeIndices = HashMap::new(); + + for qubit in 0..dag.num_qubits() { + let wire = Wire::Qubit(Qubit(qubit as u32)); + + for current_gate_idx in dag.nodes_on_wire(py, &wire, false) { + // get the commutation set associated with the current wire, or create a new + // index set containing the current gate + let commutation_entry = commutation_set + .entry(wire.clone()) + .or_insert_with(|| vec![vec![current_gate_idx]]); + + // we can unwrap as we know the commutation entry has at least one element + let last = commutation_entry.last_mut().unwrap(); + + // if the current gate index is not in the set, check whether it commutes with + // the previous nodes -- if yes, add it to the commutation set + if !last.contains(¤t_gate_idx) { + let mut all_commute = true; + + for prev_gate_idx in last.iter() { + // if the node is an input/output node, they do not commute, so we only + // continue if the nodes are operation nodes + if let (NodeType::Operation(packed_inst0), NodeType::Operation(packed_inst1)) = + (&dag.dag[current_gate_idx], &dag.dag[*prev_gate_idx]) + { + let op1 = packed_inst0.op.view(); + let op2 = packed_inst1.op.view(); + let params1 = packed_inst0.params_view(); + let params2 = packed_inst1.params_view(); + let qargs1 = dag.get_qargs(packed_inst0.qubits); + let qargs2 = dag.get_qargs(packed_inst1.qubits); + let cargs1 = dag.get_cargs(packed_inst0.clbits); + let cargs2 = dag.get_cargs(packed_inst1.clbits); + + all_commute = commutation_checker.commute_inner( + py, + &op1, + params1, + packed_inst0.extra_attrs.as_deref(), + qargs1, + cargs1, + &op2, + params2, + packed_inst1.extra_attrs.as_deref(), + qargs2, + cargs2, + MAX_NUM_QUBITS, + )?; + if !all_commute { + break; + } + } else { + all_commute = false; + break; + } + } + + if all_commute { + // all commute, add to current list + last.push(current_gate_idx); + } else { + // does not commute, create new list + commutation_entry.push(vec![current_gate_idx]); + } + } + + node_indices.insert( + (current_gate_idx, wire.clone()), + commutation_entry.len() - 1, + ); + } + } + + Ok((commutation_set, node_indices)) +} + +#[pyfunction] +#[pyo3(signature = (dag, commutation_checker))] +pub(crate) fn analyze_commutations( + py: Python, + dag: &mut DAGCircuit, + commutation_checker: &mut CommutationChecker, +) -> PyResult> { + // This returns two HashMaps: + // * The commuting nodes per wire: {wire: [commuting_nodes_1, commuting_nodes_2, ...]} + // * The index in which commutation set a given node is located on a wire: {(node, wire): index} + // The Python dict will store both of these dictionaries in one. + let (commutation_set, node_indices) = analyze_commutations_inner(py, dag, commutation_checker)?; + + let out_dict = PyDict::new_bound(py); + + // First set the {wire: [commuting_nodes_1, ...]} bit + for (wire, commutations) in commutation_set { + // we know all wires are of type Wire::Qubit, since in analyze_commutations_inner + // we only iterater over the qubits + let py_wire = match wire { + Wire::Qubit(q) => dag.qubits.get(q).unwrap().to_object(py), + _ => return Err(PyValueError::new_err("Unexpected wire type.")), + }; + + out_dict.set_item( + py_wire, + PyList::new_bound( + py, + commutations.iter().map(|inner| { + PyList::new_bound( + py, + inner + .iter() + .map(|node_index| dag.get_node(py, *node_index).unwrap()), + ) + }), + ), + )?; + } + + // Then we add the {(node, wire): index} dictionary + for ((node_index, wire), index) in node_indices { + let py_wire = match wire { + Wire::Qubit(q) => dag.qubits.get(q).unwrap().to_object(py), + _ => return Err(PyValueError::new_err("Unexpected wire type.")), + }; + out_dict.set_item((dag.get_node(py, node_index)?, py_wire), index)?; + } + + Ok(out_dict.unbind()) +} + +#[pymodule] +pub fn commutation_analysis(m: &Bound) -> PyResult<()> { + m.add_wrapped(wrap_pyfunction!(analyze_commutations))?; + Ok(()) +} diff --git a/crates/accelerate/src/commutation_checker.rs b/crates/accelerate/src/commutation_checker.rs index 6fd9d58a7c23..b00d7c624c92 100644 --- a/crates/accelerate/src/commutation_checker.rs +++ b/crates/accelerate/src/commutation_checker.rs @@ -69,7 +69,7 @@ where /// lookups. It's not meant to be a public facing Python object though and only used /// internally by the Python class. #[pyclass(module = "qiskit._accelerate.commutation_checker")] -struct CommutationChecker { +pub struct CommutationChecker { library: CommutationLibrary, cache_max_entries: usize, cache: HashMap<(String, String), CommutationCacheEntry>, @@ -227,7 +227,7 @@ impl CommutationChecker { impl CommutationChecker { #[allow(clippy::too_many_arguments)] - fn commute_inner( + pub fn commute_inner( &mut self, py: Python, op1: &OperationRef, diff --git a/crates/accelerate/src/lib.rs b/crates/accelerate/src/lib.rs index 3a8c4bf51071..6561dd258614 100644 --- a/crates/accelerate/src/lib.rs +++ b/crates/accelerate/src/lib.rs @@ -15,6 +15,7 @@ use std::env; use pyo3::import_exception; pub mod circuit_library; +pub mod commutation_analysis; pub mod commutation_checker; pub mod convert_2q_block_matrix; pub mod dense_layout; diff --git a/crates/circuit/src/dag_circuit.rs b/crates/circuit/src/dag_circuit.rs index 1eb27b71d9d9..06233618660e 100644 --- a/crates/circuit/src/dag_circuit.rs +++ b/crates/circuit/src/dag_circuit.rs @@ -5528,7 +5528,7 @@ impl DAGCircuit { /// Get the nodes on the given wire. /// /// Note: result is empty if the wire is not in the DAG. - fn nodes_on_wire(&self, py: Python, wire: &Wire, only_ops: bool) -> Vec { + pub fn nodes_on_wire(&self, py: Python, wire: &Wire, only_ops: bool) -> Vec { let mut nodes = Vec::new(); let mut current_node = match wire { Wire::Qubit(qubit) => self.qubit_io_map.get(qubit.0 as usize).map(|x| x[0]), diff --git a/crates/circuit/src/interner.rs b/crates/circuit/src/interner.rs index a8ac269b1a18..a72efb037afb 100644 --- a/crates/circuit/src/interner.rs +++ b/crates/circuit/src/interner.rs @@ -105,9 +105,7 @@ where /// `Interner::get_default` to reliably work correctly without a hash lookup (though ideally /// we'd just use specialisation to do that). pub fn new() -> Self { - let mut set = IndexSet::with_capacity_and_hasher(1, Default::default()); - set.insert(Default::default()); - Self(set) + Self::with_capacity(1) } /// Retrieve the key corresponding to the default store, without any hash or equality lookup. @@ -126,11 +124,14 @@ where } } + /// Create an interner with enough space to hold `capacity` entries. + /// + /// Note that the default item of the interner is always allocated and given a key immediately, + /// which will use one slot of the capacity. pub fn with_capacity(capacity: usize) -> Self { - Self(IndexSet::with_capacity_and_hasher( - capacity, - ::ahash::RandomState::new(), - )) + let mut set = IndexSet::with_capacity_and_hasher(capacity, ::ahash::RandomState::new()); + set.insert(Default::default()); + Self(set) } } @@ -196,3 +197,21 @@ where } } } + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn default_key_exists() { + let mut interner = Interner::<[u32]>::new(); + assert_eq!(interner.get_default(), interner.get_default()); + assert_eq!(interner.get(interner.get_default()), &[]); + assert_eq!(interner.insert_owned(Vec::new()), interner.get_default()); + assert_eq!(interner.insert(&[]), interner.get_default()); + + let capacity = Interner::::with_capacity(4); + assert_eq!(capacity.get_default(), capacity.get_default()); + assert_eq!(capacity.get(capacity.get_default()), ""); + } +} diff --git a/crates/pyext/src/lib.rs b/crates/pyext/src/lib.rs index 24a4badf6539..fdb2bff9a21d 100644 --- a/crates/pyext/src/lib.rs +++ b/crates/pyext/src/lib.rs @@ -13,15 +13,15 @@ use pyo3::prelude::*; use qiskit_accelerate::{ - circuit_library::circuit_library, commutation_checker::commutation_checker, - convert_2q_block_matrix::convert_2q_block_matrix, dense_layout::dense_layout, - error_map::error_map, euler_one_qubit_decomposer::euler_one_qubit_decomposer, - isometry::isometry, nlayout::nlayout, optimize_1q_gates::optimize_1q_gates, - pauli_exp_val::pauli_expval, results::results, sabre::sabre, sampled_exp_val::sampled_exp_val, - sparse_pauli_op::sparse_pauli_op, star_prerouting::star_prerouting, - stochastic_swap::stochastic_swap, synthesis::synthesis, target_transpiler::target, - two_qubit_decompose::two_qubit_decompose, uc_gate::uc_gate, utils::utils, - vf2_layout::vf2_layout, + circuit_library::circuit_library, commutation_analysis::commutation_analysis, + commutation_checker::commutation_checker, convert_2q_block_matrix::convert_2q_block_matrix, + dense_layout::dense_layout, error_map::error_map, + euler_one_qubit_decomposer::euler_one_qubit_decomposer, isometry::isometry, nlayout::nlayout, + optimize_1q_gates::optimize_1q_gates, pauli_exp_val::pauli_expval, results::results, + sabre::sabre, sampled_exp_val::sampled_exp_val, sparse_pauli_op::sparse_pauli_op, + star_prerouting::star_prerouting, stochastic_swap::stochastic_swap, synthesis::synthesis, + target_transpiler::target, two_qubit_decompose::two_qubit_decompose, uc_gate::uc_gate, + utils::utils, vf2_layout::vf2_layout, }; #[inline(always)] @@ -62,5 +62,6 @@ fn _accelerate(m: &Bound) -> PyResult<()> { add_submodule(m, utils, "utils")?; add_submodule(m, vf2_layout, "vf2_layout")?; add_submodule(m, commutation_checker, "commutation_checker")?; + add_submodule(m, commutation_analysis, "commutation_analysis")?; Ok(()) } diff --git a/qiskit/__init__.py b/qiskit/__init__.py index 67384b38971a..38a9f5952425 100644 --- a/qiskit/__init__.py +++ b/qiskit/__init__.py @@ -87,6 +87,7 @@ sys.modules["qiskit._accelerate.synthesis.linear"] = _accelerate.synthesis.linear sys.modules["qiskit._accelerate.synthesis.clifford"] = _accelerate.synthesis.clifford sys.modules["qiskit._accelerate.commutation_checker"] = _accelerate.commutation_checker +sys.modules["qiskit._accelerate.commutation_analysis"] = _accelerate.commutation_analysis sys.modules["qiskit._accelerate.synthesis.linear_phase"] = _accelerate.synthesis.linear_phase from qiskit.exceptions import QiskitError, MissingOptionalLibraryError diff --git a/qiskit/transpiler/passes/optimization/commutation_analysis.py b/qiskit/transpiler/passes/optimization/commutation_analysis.py index 12ed7145eec7..d801e4775937 100644 --- a/qiskit/transpiler/passes/optimization/commutation_analysis.py +++ b/qiskit/transpiler/passes/optimization/commutation_analysis.py @@ -12,11 +12,9 @@ """Analysis pass to find commutation relations between DAG nodes.""" -from collections import defaultdict - from qiskit.circuit.commutation_library import SessionCommutationChecker as scc -from qiskit.dagcircuit import DAGOpNode from qiskit.transpiler.basepasses import AnalysisPass +from qiskit._accelerate.commutation_analysis import analyze_commutations class CommutationAnalysis(AnalysisPass): @@ -33,6 +31,7 @@ def __init__(self, *, _commutation_checker=None): # do not care about commutations of all gates, but just a subset if _commutation_checker is None: _commutation_checker = scc + self.comm_checker = _commutation_checker def run(self, dag): @@ -42,49 +41,4 @@ def run(self, dag): into the ``property_set``. """ # Initiate the commutation set - self.property_set["commutation_set"] = defaultdict(list) - - # Build a dictionary to keep track of the gates on each qubit - # The key with format (wire) will store the lists of commutation sets - # The key with format (node, wire) will store the index of the commutation set - # on the specified wire, thus, for example: - # self.property_set['commutation_set'][wire][(node, wire)] will give the - # commutation set that contains node. - - for wire in dag.qubits: - self.property_set["commutation_set"][wire] = [] - - # Add edges to the dictionary for each qubit - for node in dag.topological_op_nodes(): - for _, _, edge_wire in dag.edges(node): - self.property_set["commutation_set"][(node, edge_wire)] = -1 - - # Construct the commutation set - for wire in dag.qubits: - - for current_gate in dag.nodes_on_wire(wire): - - current_comm_set = self.property_set["commutation_set"][wire] - if not current_comm_set: - current_comm_set.append([current_gate]) - - if current_gate not in current_comm_set[-1]: - does_commute = True - - # Check if the current gate commutes with all the gates in the current block - for prev_gate in current_comm_set[-1]: - does_commute = ( - isinstance(current_gate, DAGOpNode) - and isinstance(prev_gate, DAGOpNode) - and self.comm_checker.commute_nodes(current_gate, prev_gate) - ) - if not does_commute: - break - - if does_commute: - current_comm_set[-1].append(current_gate) - else: - current_comm_set.append([current_gate]) - - temp_len = len(current_comm_set) - self.property_set["commutation_set"][(current_gate, wire)] = temp_len - 1 + self.property_set["commutation_set"] = analyze_commutations(dag, self.comm_checker.cc) diff --git a/qiskit/visualization/gate_map.py b/qiskit/visualization/gate_map.py index b950c84c902a..eb20623f0c8c 100644 --- a/qiskit/visualization/gate_map.py +++ b/qiskit/visualization/gate_map.py @@ -945,6 +945,7 @@ def plot_gate_map( font_color, ax, filename, + planar=rx.is_planar(coupling_map.graph.to_undirected(multigraph=False)), ) @@ -966,6 +967,8 @@ def plot_coupling_map( font_color="white", ax=None, filename=None, + *, + planar=True, ): """Plots an arbitrary coupling map of qubits (embedded in a plane). @@ -987,6 +990,7 @@ def plot_coupling_map( font_color (str): The font color for the qubit labels. ax (Axes): A Matplotlib axes instance. filename (str): file path to save image to. + planar (bool): If the coupling map is planar or not. Default: ``True`` (i.e. it is planar) Returns: Figure: A Matplotlib figure instance. @@ -1057,7 +1061,14 @@ def plot_coupling_map( if font_size is None: max_characters = max(1, max(len(str(x)) for x in qubit_labels)) - font_size = max(int(20 / max_characters), 1) + if max_characters == 1: + font_size = 20 + elif max_characters == 2: + font_size = 14 + elif max_characters == 3: + font_size = 12 + else: + font_size = 1 def color_node(node): if qubit_coordinates: @@ -1065,8 +1076,6 @@ def color_node(node): "label": str(qubit_labels[node]), "color": f'"{qubit_color[node]}"', "fillcolor": f'"{qubit_color[node]}"', - "style": "filled", - "shape": "circle", "pos": f'"{qubit_coordinates[node][0]},{qubit_coordinates[node][1]}"', "pin": "True", } @@ -1075,11 +1084,11 @@ def color_node(node): "label": str(qubit_labels[node]), "color": f'"{qubit_color[node]}"', "fillcolor": f'"{qubit_color[node]}"', - "style": "filled", - "shape": "circle", } + out_dict["style"] = "filled" + out_dict["shape"] = "circle" out_dict["fontcolor"] = f'"{font_color}"' - out_dict["fontsize"] = str(font_size) + out_dict["fontsize"] = f'"{str(font_size)}!"' out_dict["height"] = str(qubit_size * px) out_dict["fixedsize"] = "True" out_dict["fontname"] = '"DejaVu Sans"' @@ -1093,9 +1102,22 @@ def color_edge(edge): } return out_dict + graph_attributes = None + if not qubit_coordinates: + if planar: + graph_attributes = { + "overlap_scaling": "-7", + "overlap": "prism", + "model": "subset", + } + else: + graph_attributes = { + "overlap": "true", + } plot = graphviz_draw( graph, method="neato", + graph_attr=graph_attributes, node_attr_fn=color_node, edge_attr_fn=color_edge, filename=filename, diff --git a/releasenotes/notes/adjust-neato-settings-3adcc0ae9e245ce9.yaml b/releasenotes/notes/adjust-neato-settings-3adcc0ae9e245ce9.yaml new file mode 100644 index 000000000000..9dec5debb2ef --- /dev/null +++ b/releasenotes/notes/adjust-neato-settings-3adcc0ae9e245ce9.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes an issue with the visualizations of some backends/coupling maps that showed as folded on their own. The + `default ``neato`` setting `_ works well in most cases. However, + ``prism`` overlap returns a more regular layout for other scenarios. diff --git a/releasenotes/notes/oxidize-commutation-analysis-d2fc81feb6ca80aa.yaml b/releasenotes/notes/oxidize-commutation-analysis-d2fc81feb6ca80aa.yaml new file mode 100644 index 000000000000..967a65bcebab --- /dev/null +++ b/releasenotes/notes/oxidize-commutation-analysis-d2fc81feb6ca80aa.yaml @@ -0,0 +1,4 @@ +--- +features_transpiler: + - | + Added a Rust implementation of :class:`.CommutationAnalysis` in :func:`.analyze_commutations`. diff --git a/test/visual/mpl/graph/references/16_qubit_gate_map.png b/test/visual/mpl/graph/references/16_qubit_gate_map.png index c76baabf1522..722b1db91523 100644 Binary files a/test/visual/mpl/graph/references/16_qubit_gate_map.png and b/test/visual/mpl/graph/references/16_qubit_gate_map.png differ diff --git a/test/visual/mpl/graph/references/27_qubit_gate_map.png b/test/visual/mpl/graph/references/27_qubit_gate_map.png index 73ef08c1c3a8..59ed9d8d5cfc 100644 Binary files a/test/visual/mpl/graph/references/27_qubit_gate_map.png and b/test/visual/mpl/graph/references/27_qubit_gate_map.png differ diff --git a/test/visual/mpl/graph/references/5_qubit_gate_map.png b/test/visual/mpl/graph/references/5_qubit_gate_map.png index 3d89cdaf9950..557901f7e9be 100644 Binary files a/test/visual/mpl/graph/references/5_qubit_gate_map.png and b/test/visual/mpl/graph/references/5_qubit_gate_map.png differ diff --git a/test/visual/mpl/graph/references/65_qubit_gate_map.png b/test/visual/mpl/graph/references/65_qubit_gate_map.png index 1e99ced00400..182d7c333bbb 100644 Binary files a/test/visual/mpl/graph/references/65_qubit_gate_map.png and b/test/visual/mpl/graph/references/65_qubit_gate_map.png differ diff --git a/test/visual/mpl/graph/references/7_qubit_gate_map.png b/test/visual/mpl/graph/references/7_qubit_gate_map.png index 1413da0a7c47..4a0ed4fe2d51 100644 Binary files a/test/visual/mpl/graph/references/7_qubit_gate_map.png and b/test/visual/mpl/graph/references/7_qubit_gate_map.png differ diff --git a/test/visual/mpl/graph/references/bloch_multivector.png b/test/visual/mpl/graph/references/bloch_multivector.png index 5b72a9d04896..896e513ef368 100644 Binary files a/test/visual/mpl/graph/references/bloch_multivector.png and b/test/visual/mpl/graph/references/bloch_multivector.png differ diff --git a/test/visual/mpl/graph/references/bloch_multivector_figsize_improvements.png b/test/visual/mpl/graph/references/bloch_multivector_figsize_improvements.png index 80e73131a39b..5f5ba75d9428 100644 Binary files a/test/visual/mpl/graph/references/bloch_multivector_figsize_improvements.png and b/test/visual/mpl/graph/references/bloch_multivector_figsize_improvements.png differ diff --git a/test/visual/mpl/graph/references/figsize.png b/test/visual/mpl/graph/references/figsize.png index 3d89cdaf9950..557901f7e9be 100644 Binary files a/test/visual/mpl/graph/references/figsize.png and b/test/visual/mpl/graph/references/figsize.png differ diff --git a/test/visual/mpl/graph/references/font_color.png b/test/visual/mpl/graph/references/font_color.png index a53f93fa4fe2..3e132fff5be4 100644 Binary files a/test/visual/mpl/graph/references/font_color.png and b/test/visual/mpl/graph/references/font_color.png differ diff --git a/test/visual/mpl/graph/references/hinton.png b/test/visual/mpl/graph/references/hinton.png index 3be80df31480..70521af917c5 100644 Binary files a/test/visual/mpl/graph/references/hinton.png and b/test/visual/mpl/graph/references/hinton.png differ diff --git a/test/visual/mpl/graph/references/histogram.png b/test/visual/mpl/graph/references/histogram.png index 3fa51ec644ed..8167908c1ba3 100644 Binary files a/test/visual/mpl/graph/references/histogram.png and b/test/visual/mpl/graph/references/histogram.png differ diff --git a/test/visual/mpl/graph/references/histogram_2_sets_with_rest.png b/test/visual/mpl/graph/references/histogram_2_sets_with_rest.png index fe11f5811931..fc6d8497b867 100644 Binary files a/test/visual/mpl/graph/references/histogram_2_sets_with_rest.png and b/test/visual/mpl/graph/references/histogram_2_sets_with_rest.png differ diff --git a/test/visual/mpl/graph/references/histogram_color.png b/test/visual/mpl/graph/references/histogram_color.png index 34f7d449616a..57a1cbabc1c0 100644 Binary files a/test/visual/mpl/graph/references/histogram_color.png and b/test/visual/mpl/graph/references/histogram_color.png differ diff --git a/test/visual/mpl/graph/references/histogram_desc_value_sort.png b/test/visual/mpl/graph/references/histogram_desc_value_sort.png index b119ae2deed4..71f87047479a 100644 Binary files a/test/visual/mpl/graph/references/histogram_desc_value_sort.png and b/test/visual/mpl/graph/references/histogram_desc_value_sort.png differ diff --git a/test/visual/mpl/graph/references/histogram_hamming.png b/test/visual/mpl/graph/references/histogram_hamming.png index 95bfe0ab1049..0fdca0e5342f 100644 Binary files a/test/visual/mpl/graph/references/histogram_hamming.png and b/test/visual/mpl/graph/references/histogram_hamming.png differ diff --git a/test/visual/mpl/graph/references/histogram_legend.png b/test/visual/mpl/graph/references/histogram_legend.png index 77fbe9c5dc0f..0cb218e12528 100644 Binary files a/test/visual/mpl/graph/references/histogram_legend.png and b/test/visual/mpl/graph/references/histogram_legend.png differ diff --git a/test/visual/mpl/graph/references/histogram_multiple_colors.png b/test/visual/mpl/graph/references/histogram_multiple_colors.png index 7edbfc07bab5..0ee70ac4360c 100644 Binary files a/test/visual/mpl/graph/references/histogram_multiple_colors.png and b/test/visual/mpl/graph/references/histogram_multiple_colors.png differ diff --git a/test/visual/mpl/graph/references/histogram_title.png b/test/visual/mpl/graph/references/histogram_title.png index c4c6859c8f2e..84e486d45e48 100644 Binary files a/test/visual/mpl/graph/references/histogram_title.png and b/test/visual/mpl/graph/references/histogram_title.png differ diff --git a/test/visual/mpl/graph/references/histogram_value_sort.png b/test/visual/mpl/graph/references/histogram_value_sort.png index e44d08e0d9f9..5f9c93e205ff 100644 Binary files a/test/visual/mpl/graph/references/histogram_value_sort.png and b/test/visual/mpl/graph/references/histogram_value_sort.png differ diff --git a/test/visual/mpl/graph/references/histogram_with_rest.png b/test/visual/mpl/graph/references/histogram_with_rest.png index 69633c1e4fdb..e1fe47fe2ba2 100644 Binary files a/test/visual/mpl/graph/references/histogram_with_rest.png and b/test/visual/mpl/graph/references/histogram_with_rest.png differ diff --git a/test/visual/mpl/graph/references/line_color.png b/test/visual/mpl/graph/references/line_color.png index 392c42fbd3ae..a7813e0ea07e 100644 Binary files a/test/visual/mpl/graph/references/line_color.png and b/test/visual/mpl/graph/references/line_color.png differ diff --git a/test/visual/mpl/graph/references/paulivec.png b/test/visual/mpl/graph/references/paulivec.png index 813a387265b1..0a0912c5cb3d 100644 Binary files a/test/visual/mpl/graph/references/paulivec.png and b/test/visual/mpl/graph/references/paulivec.png differ diff --git a/test/visual/mpl/graph/references/qsphere.png b/test/visual/mpl/graph/references/qsphere.png index f344accd2856..d687e7c8871d 100644 Binary files a/test/visual/mpl/graph/references/qsphere.png and b/test/visual/mpl/graph/references/qsphere.png differ diff --git a/test/visual/mpl/graph/references/qubit_color.png b/test/visual/mpl/graph/references/qubit_color.png index c4669adfa799..789e1c71278e 100644 Binary files a/test/visual/mpl/graph/references/qubit_color.png and b/test/visual/mpl/graph/references/qubit_color.png differ diff --git a/test/visual/mpl/graph/references/qubit_labels.png b/test/visual/mpl/graph/references/qubit_labels.png index 9ddc259a367c..d2f020048168 100644 Binary files a/test/visual/mpl/graph/references/qubit_labels.png and b/test/visual/mpl/graph/references/qubit_labels.png differ diff --git a/test/visual/mpl/graph/references/qubit_size.png b/test/visual/mpl/graph/references/qubit_size.png index fa317e6b9d14..f8f7a660f53f 100644 Binary files a/test/visual/mpl/graph/references/qubit_size.png and b/test/visual/mpl/graph/references/qubit_size.png differ diff --git a/test/visual/mpl/graph/references/state_city.png b/test/visual/mpl/graph/references/state_city.png index 990c433c9162..a9af6d8b87f2 100644 Binary files a/test/visual/mpl/graph/references/state_city.png and b/test/visual/mpl/graph/references/state_city.png differ diff --git a/test/visual/mpl/graph/test_graph_matplotlib_drawer.py b/test/visual/mpl/graph/test_graph_matplotlib_drawer.py index 20fae107d30d..7100602f72a5 100644 --- a/test/visual/mpl/graph/test_graph_matplotlib_drawer.py +++ b/test/visual/mpl/graph/test_graph_matplotlib_drawer.py @@ -113,7 +113,7 @@ def test_plot_bloch_multivector(self): FAILURE_DIFF_DIR, FAILURE_PREFIX, ) - self.assertGreaterEqual(ratio, 0.99) + self.assertGreaterEqual(ratio, 0.99, msg=fname) def test_plot_state_hinton(self): """test plot_state_hinton""" @@ -437,7 +437,7 @@ def test_plot_7_qubit_gate_map(self): FAILURE_DIFF_DIR, FAILURE_PREFIX, ) - self.assertGreaterEqual(ratio, 0.99) + self.assertGreaterEqual(ratio, 0.99, msg=fname) def test_plot_16_qubit_gate_map(self): """Test plot_gate_map using 16 qubit backend""" @@ -455,7 +455,7 @@ def test_plot_16_qubit_gate_map(self): FAILURE_DIFF_DIR, FAILURE_PREFIX, ) - self.assertGreaterEqual(ratio, 0.99) + self.assertGreaterEqual(ratio, 0.99, msg=fname) def test_plot_27_qubit_gate_map(self): """Test plot_gate_map using 27 qubit backend""" @@ -527,7 +527,7 @@ def test_qubit_size(self): FAILURE_DIFF_DIR, FAILURE_PREFIX, ) - self.assertGreaterEqual(ratio, 0.99) + self.assertGreaterEqual(ratio, 0.99, msg=fname) def test_qubit_color(self): """Test qubit_color parameter of plot_gate_map""" @@ -545,7 +545,7 @@ def test_qubit_color(self): FAILURE_DIFF_DIR, FAILURE_PREFIX, ) - self.assertGreaterEqual(ratio, 0.99) + self.assertGreaterEqual(ratio, 0.99, msg=fname) def test_qubit_labels(self): """Test qubit_labels parameter of plot_gate_map""" @@ -658,7 +658,7 @@ def test_plot_bloch_multivector_figsize_improvements(self): FAILURE_DIFF_DIR, FAILURE_PREFIX, ) - self.assertGreaterEqual(ratio, 0.99) + self.assertGreaterEqual(ratio, 0.99, msg=fname) if __name__ == "__main__":