Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address NumPy and NotImplemented deprecation warnings #6465

Merged
merged 6 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def test_approx_eq_mixed_primitives():

def test_numpy_dtype_compatibility():
i_a, i_b, i_c = 0, 1, 2
i_types = [np.intc, np.intp, np.int0, np.int8, np.int16, np.int32, np.int64]
i_types = [np.intc, np.intp, np.int8, np.int16, np.int32, np.int64]
for i_type in i_types:
assert cirq.approx_eq(i_type(i_a), i_type(i_b), atol=1)
assert not cirq.approx_eq(i_type(i_a), i_type(i_c), atol=1)
u_types = [np.uint, np.uint0, np.uint8, np.uint16, np.uint32, np.uint64]
u_types = [np.uint, np.uintp, np.uint8, np.uint16, np.uint32, np.uint64]
for u_type in u_types:
assert cirq.approx_eq(u_type(i_a), u_type(i_b), atol=1)
assert not cirq.approx_eq(u_type(i_a), u_type(i_c), atol=1)
Expand Down
6 changes: 4 additions & 2 deletions cirq-core/cirq/protocols/resolve_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ def resolve_parameters(
if isinstance(val, (list, tuple)):
return cast(T, type(val)(resolve_parameters(e, param_resolver, recursive) for e in val))

is_parameterized = getattr(val, '_is_parameterized_', None)
if is_parameterized is not None and not is_parameterized():
is_parameterized = (
val._is_parameterized_() if hasattr(val, '_is_parameterized_') else NotImplemented
)
if is_parameterized is not NotImplemented and not is_parameterized:
return val

getter = getattr(val, '_resolve_parameters_', None)
Expand Down
4 changes: 2 additions & 2 deletions cirq-core/cirq/sim/simulation_state_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def _act_on_fallback_(
return True

def add_qubits(self, qubits):
ret = super().add_qubits(qubits)
return self if NotImplemented else ret
super().add_qubits(qubits)
return self


class DelegatingAncillaZ(cirq.Gate):
Expand Down