Skip to content

Commit a4ec796

Browse files
authored
Address NumPy and NotImplemented deprecation warnings (#6465)
* Replace deprecated numpy aliases for dtype-s `np.int0` --> `np.intp` and `np.uint0` --> `np.uintp` * Address deprecation warning about NotImplemented used as boolean
1 parent a8bd9a5 commit a4ec796

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

cirq-core/cirq/protocols/approximate_equality_protocol_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ def test_approx_eq_mixed_primitives():
4747

4848
def test_numpy_dtype_compatibility():
4949
i_a, i_b, i_c = 0, 1, 2
50-
i_types = [np.intc, np.intp, np.int0, np.int8, np.int16, np.int32, np.int64]
50+
i_types = [np.intc, np.intp, np.int8, np.int16, np.int32, np.int64]
5151
for i_type in i_types:
5252
assert cirq.approx_eq(i_type(i_a), i_type(i_b), atol=1)
5353
assert not cirq.approx_eq(i_type(i_a), i_type(i_c), atol=1)
54-
u_types = [np.uint, np.uint0, np.uint8, np.uint16, np.uint32, np.uint64]
54+
u_types = [np.uint, np.uintp, np.uint8, np.uint16, np.uint32, np.uint64]
5555
for u_type in u_types:
5656
assert cirq.approx_eq(u_type(i_a), u_type(i_b), atol=1)
5757
assert not cirq.approx_eq(u_type(i_a), u_type(i_c), atol=1)

cirq-core/cirq/protocols/resolve_parameters.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@ def resolve_parameters(
178178
if isinstance(val, (list, tuple)):
179179
return cast(T, type(val)(resolve_parameters(e, param_resolver, recursive) for e in val))
180180

181-
is_parameterized = getattr(val, '_is_parameterized_', None)
182-
if is_parameterized is not None and not is_parameterized():
181+
is_parameterized = (
182+
val._is_parameterized_() if hasattr(val, '_is_parameterized_') else NotImplemented
183+
)
184+
if is_parameterized is not NotImplemented and not is_parameterized:
183185
return val
184186

185187
getter = getattr(val, '_resolve_parameters_', None)

cirq-core/cirq/sim/simulation_state_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def _act_on_fallback_(
4343
return True
4444

4545
def add_qubits(self, qubits):
46-
ret = super().add_qubits(qubits)
47-
return self if NotImplemented else ret
46+
super().add_qubits(qubits)
47+
return self
4848

4949

5050
class DelegatingAncillaZ(cirq.Gate):

0 commit comments

Comments
 (0)