diff --git a/qiskit/quantum_info/operators/symplectic/clifford.py b/qiskit/quantum_info/operators/symplectic/clifford.py index e1cd367d22cf..c9b8c4d3520a 100644 --- a/qiskit/quantum_info/operators/symplectic/clifford.py +++ b/qiskit/quantum_info/operators/symplectic/clifford.py @@ -163,8 +163,17 @@ def __init__(self, data, validate=True, copy=True): # Initialize StabilizerTable directly from the data else: - if isinstance(data, (list, np.ndarray)) and np.asarray(data, dtype=bool).ndim == 2: - data = np.array(data, dtype=bool, copy=copy) + if ( + isinstance(data, (list, np.ndarray)) + and (data_asarray := np.asarray(data, dtype=bool)).ndim == 2 + ): + # This little dance is to avoid Numpy 1/2 incompatiblities between the availability + # and meaning of the 'copy' argument in 'array' and 'asarray', when the input needs + # its dtype converting. 'asarray' prefers to return 'self' if possible in both. + if copy and data_asarray is data: + data = data_asarray.copy() + else: + data = data_asarray if data.shape[0] == data.shape[1]: self.tableau = self._stack_table_phase( data, np.zeros(data.shape[0], dtype=bool) diff --git a/qiskit/visualization/array.py b/qiskit/visualization/array.py index b076e38b174d..3a8ef2917156 100644 --- a/qiskit/visualization/array.py +++ b/qiskit/visualization/array.py @@ -33,7 +33,7 @@ def _num_to_latex(raw_value, decimals=15, first_term=True, coefficient=False): """ import sympy # runtime import - raw_value = np.around(raw_value, decimals=decimals) + raw_value = np.around(raw_value, decimals=decimals).item() value = sympy.nsimplify(raw_value, rational=False) if isinstance(value, sympy.core.numbers.Rational) and value.denominator > 50: diff --git a/releasenotes/notes/numpy-2.0-2f3e35bd42c48518.yaml b/releasenotes/notes/numpy-2.0-2f3e35bd42c48518.yaml new file mode 100644 index 000000000000..3595f2f936bd --- /dev/null +++ b/releasenotes/notes/numpy-2.0-2f3e35bd42c48518.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + This release of Qiskit finalizes support for NumPy 2.0. Qiskit will continue to support both + Numpy 1.x and 2.x for the foreseeable future. diff --git a/requirements.txt b/requirements.txt index 0a4f0f32c5a9..539f9587994d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ rustworkx>=0.14.0 -numpy>=1.17,<2 +numpy>=1.17,<3 scipy>=1.5 sympy>=1.3 dill>=0.3 python-dateutil>=2.8.0 stevedore>=3.0.0 typing-extensions -symengine>=0.11 \ No newline at end of file +symengine>=0.11