def test_charset_error(self): with pytest.raises(ValueError, match=r"Charset 'nope' is not supported."): CircuitDrawer(dummy_raw_operation_grid, dummy_raw_observable_grid, Wires(range(6)), charset="nope")
def test_charset_class(self, charset): drawer_class = CircuitDrawer(dummy_raw_operation_grid, dummy_raw_observable_grid, Wires(range(6)), charset=charset) assert isinstance(drawer_class.charset, charset)
def test_charset_string(self, charset): drawer_str = CircuitDrawer(dummy_raw_operation_grid, dummy_raw_observable_grid, Wires(range(6)), charset=charset) assert isinstance(drawer_str.charset, CHARSETS[charset])
def test_charset_default(self): drawer_None = CircuitDrawer(dummy_raw_operation_grid, dummy_raw_observable_grid, Wires(range(6)), charset=None) assert isinstance(drawer_None.charset, UnicodeCharSet)
def test_move_multi_wire_gates(self, grid, target_grid): """Test that decorations are properly resolved.""" operator_grid = grid.copy() raw_operator_grid = operator_grid.raw_grid # make a dummy observable grid raw_observable_grid = [[None] for _ in range(len(raw_operator_grid))] drawer = CircuitDrawer(raw_operator_grid, raw_observable_grid, Wires(range(10))) drawer.move_multi_wire_gates(operator_grid) assert_nested_lists_equal(operator_grid.raw_grid, target_grid.raw_grid)
def test_resolve_decorations(self, grid, target_representation_grid): """Test that decorations are properly resolved.""" representation_grid = Grid() raw_operator_grid = grid.raw_grid # make a dummy observable grid raw_observable_grid = [[None] for _ in range(len(raw_operator_grid))] drawer = CircuitDrawer(raw_operator_grid, raw_observable_grid, Wires(range(10))) drawer.resolve_decorations(grid, representation_grid) assert_nested_lists_equal(representation_grid.raw_grid, target_representation_grid.raw_grid)
def dummy_circuit_drawer(): """A dummy CircuitDrawer instance.""" return CircuitDrawer(dummy_raw_operation_grid, dummy_raw_observable_grid, Wires(range(6)))