diff --git a/cirq-core/cirq/circuits/qasm_output.py b/cirq-core/cirq/circuits/qasm_output.py index 5194561f980..ca8c5a949db 100644 --- a/cirq-core/cirq/circuits/qasm_output.py +++ b/cirq-core/cirq/circuits/qasm_output.py @@ -43,7 +43,7 @@ def __init__(self, theta, phi, lmda) -> None: self.phi = phi % 2 @staticmethod - def from_matrix(mat: np.array) -> 'QasmUGate': + def from_matrix(mat: np.ndarray) -> 'QasmUGate': pre_phase, rotation, post_phase = linalg.deconstruct_single_qubit_matrix_into_angles(mat) return QasmUGate( rotation / np.pi, @@ -115,7 +115,7 @@ def _value_equality_values_(self): return self.kak @staticmethod - def from_matrix(mat: np.array, atol=1e-8) -> 'QasmTwoQubitGate': + def from_matrix(mat: np.ndarray, atol=1e-8) -> 'QasmTwoQubitGate': """Creates a QasmTwoQubitGate from the given matrix. Args: diff --git a/cirq-core/cirq/experiments/random_quantum_circuit_generation.py b/cirq-core/cirq/experiments/random_quantum_circuit_generation.py index 04243631bf1..c759afa97be 100644 --- a/cirq-core/cirq/experiments/random_quantum_circuit_generation.py +++ b/cirq-core/cirq/experiments/random_quantum_circuit_generation.py @@ -305,7 +305,7 @@ class CircuitLibraryCombination: """ layer: Optional[Any] - combinations: np.array + combinations: np.ndarray pairs: List[QidPairT] diff --git a/cirq-core/cirq/ion/ion_decomposition_test.py b/cirq-core/cirq/ion/ion_decomposition_test.py index 64febcb9c2b..760e4e89323 100644 --- a/cirq-core/cirq/ion/ion_decomposition_test.py +++ b/cirq-core/cirq/ion/ion_decomposition_test.py @@ -117,7 +117,7 @@ def assert_ms_depth_below(operations, threshold): (2, _random_double_MS_effect()) for _ in range(10) ]) # yapf: enable -def test_two_to_ops(max_ms_depth: int, effect: np.array): +def test_two_to_ops(max_ms_depth: int, effect: np.ndarray): q0 = cirq.NamedQubit('q0') q1 = cirq.NamedQubit('q1') diff --git a/cirq-core/cirq/qis/clifford_tableau.py b/cirq-core/cirq/qis/clifford_tableau.py index 60db36bb53c..8a192e6c24e 100644 --- a/cirq-core/cirq/qis/clifford_tableau.py +++ b/cirq-core/cirq/qis/clifford_tableau.py @@ -240,33 +240,33 @@ def __init__(self, num_qubits, initial_state: int = 0): self._zs[self.n + i, i] = True @property - def xs(self) -> np.array: + def xs(self) -> np.ndarray: return self._xs[:-1, :] @xs.setter - def xs(self, new_xs: np.array) -> None: + def xs(self, new_xs: np.ndarray) -> None: assert np.shape(new_xs) == (2 * self.n, self.n) self._xs[:-1, :] = np.array(new_xs).astype(bool) @property - def zs(self) -> np.array: + def zs(self) -> np.ndarray: return self._zs[:-1, :] @zs.setter - def zs(self, new_zs: np.array) -> None: + def zs(self, new_zs: np.ndarray) -> None: assert np.shape(new_zs) == (2 * self.n, self.n) self._zs[:-1, :] = np.array(new_zs).astype(bool) @property - def rs(self) -> np.array: + def rs(self) -> np.ndarray: return self._rs[:-1] @rs.setter - def rs(self, new_rs: np.array) -> None: + def rs(self, new_rs: np.ndarray) -> None: assert np.shape(new_rs) == (2 * self.n,) self._rs[:-1] = np.array(new_rs).astype(bool) - def matrix(self) -> np.array: + def matrix(self) -> np.ndarray: """Returns the 2n * 2n matrix representation of the Clifford tableau.""" return np.concatenate([self.xs, self.zs], axis=1) diff --git a/cirq-core/cirq/sim/density_matrix_utils.py b/cirq-core/cirq/sim/density_matrix_utils.py index f4d5fb68012..c04d69f2c4d 100644 --- a/cirq-core/cirq/sim/density_matrix_utils.py +++ b/cirq-core/cirq/sim/density_matrix_utils.py @@ -222,7 +222,7 @@ def _probs( def _validate_density_matrix_qid_shape( - density_matrix: np.array, qid_shape: Tuple[int, ...] + density_matrix: np.ndarray, qid_shape: Tuple[int, ...] ) -> Tuple[int, ...]: """Validates that a tensor's shape is a valid shape for qids and returns the qid shape. diff --git a/cirq-google/cirq_google/calibration/engine_simulator.py b/cirq-google/cirq_google/calibration/engine_simulator.py index 876e8e24874..72b41e4fc7c 100644 --- a/cirq-google/cirq_google/calibration/engine_simulator.py +++ b/cirq-google/cirq_google/calibration/engine_simulator.py @@ -373,7 +373,7 @@ def create_from_characterizations_sqrt_iswap( ideal_when_missing_parameter=ideal_when_missing_parameter, ) - def final_state_vector(self, program: cirq.Circuit) -> np.array: + def final_state_vector(self, program: cirq.Circuit) -> np.ndarray: result = self.simulate(program) return result.state_vector() diff --git a/cirq-google/cirq_google/calibration/phased_fsim.py b/cirq-google/cirq_google/calibration/phased_fsim.py index 30f273dc8a9..f62393adbcb 100644 --- a/cirq-google/cirq_google/calibration/phased_fsim.py +++ b/cirq-google/cirq_google/calibration/phased_fsim.py @@ -1033,7 +1033,7 @@ def with_zeta_chi_gamma_compensated( (cirq.rz(0.5 * gamma - beta).on(a), cirq.rz(0.5 * gamma + beta).on(b)), ) - def _unitary_(self) -> np.array: + def _unitary_(self) -> np.ndarray: """Implements Cirq's `unitary` protocol for this object.""" p = np.exp(-np.pi * 1j * self.phase_exponent) return ( diff --git a/examples/stabilizer_code.py b/examples/stabilizer_code.py index b4fc09d408b..ef0c0427de9 100644 --- a/examples/stabilizer_code.py +++ b/examples/stabilizer_code.py @@ -114,8 +114,8 @@ def _gaussian_elimination( def _transfer_to_standard_form( - M: np.array, n: int, k: int -) -> Tuple[np.array, np.array, np.array, int]: + M: np.ndarray, n: int, k: int +) -> Tuple[np.ndarray, np.ndarray, np.ndarray, int]: """Puts the stabilizer matrix in its standardized form, as in section 4.1 of the thesis. Args: