-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix type-checking issues for numpy-2.3.3 #7661
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
Fix type-checking issues for numpy-2.3.3 #7661
Conversation
…antumlib#7658)" This reverts commit 2845910.
…ulationState The `dtype` argument can be either a Python type, e.g., `np.complex64`, or np.dtype, such as `np.dtype(np.complex64)`. Allow either case.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7661 +/- ##
=======================================
Coverage 99.37% 99.37%
=======================================
Files 1082 1082
Lines 96700 96700
=======================================
Hits 96097 96097
Misses 603 603 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check/mypy
fails for me locally for one of the files.
copy.M = self.M[axes][:, axes] | ||
copy.gamma = self.gamma[axes] | ||
copy.v = self.v[axes] | ||
copy.s = self.s[axes] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fail for me locally with Python 3.11, Numpy 2.2.6, and mypy 1.17.1.
# ./check/mypy
cirq-core/cirq/sim/clifford/stabilizer_state_ch_form.py:291: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[Any]]", variable has type "ndarray[tuple[int, int], dtype[Any]]") [assignment]
cirq-core/cirq/sim/clifford/stabilizer_state_ch_form.py:292: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[Any]]", variable has type "ndarray[tuple[int], dtype[Any]]") [assignment]
cirq-core/cirq/sim/clifford/stabilizer_state_ch_form.py:293: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[Any]]", variable has type "ndarray[tuple[int], dtype[Any]]") [assignment]
cirq-core/cirq/sim/clifford/stabilizer_state_ch_form.py:294: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[Any]]", variable has type "ndarray[tuple[int], dtype[Any]]") [assignment]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack. Please update to numpy>=2.3 in your development environment. These lines were decorated with # type: ignore
comments which became unnecessary after typing enhancements in numpy-2.3. Testing with numpy-2.2 exposes the ignored errors.
For type checking we can require the latest numpy version (as installed in the CI job) so that type checks have the most up-to-date numpy annotations.
StateVectorSimulationState
Fixes #7657