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

Fix remaining mypy/numpy errors #5677

Merged
merged 4 commits into from
Jul 7, 2022

Conversation

pavoljuhas
Copy link
Collaborator

  • Fix type mismatch in _BufferedStateVector.create argument
  • Fix type of the measurements argument to CliffordState.apply_measurement
  • Fix type spec of the dtype argument to StateVectorSimulationState

check/mypy --next now passes without errors.

@pavoljuhas pavoljuhas requested review from a team, vtomole and cduck as code owners July 7, 2022 18:40
@pavoljuhas pavoljuhas requested a review from tanujkhattar July 7, 2022 18:40
@CirqBot CirqBot added the size: S 10< lines changed <50 label Jul 7, 2022
@pavoljuhas pavoljuhas linked an issue Jul 7, 2022 that may be closed by this pull request
@pavoljuhas
Copy link
Collaborator Author

Partially implements #3767

Copy link
Collaborator

@dabacon dabacon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question.

args = state_vector_simulation_state.StateVectorSimulationState(
available_buffer=np.empty_like(state_vector),
qubits=qubits,
prng=np.random.RandomState(),
initial_state=state_vector.copy(),
dtype=state_vector.dtype,
dtype=complex_dtype,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, since this is in the simulation direct call path, should we just do a cast here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure state_vector.dtype is complex?
If so we can make it simpler with cast.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I misread where this is, this is in the testing of consistent act_on. Think this is fine. Not sure we can assume state_vector dtype is complex, so this works.

Copy link
Collaborator

@dabacon dabacon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

args = state_vector_simulation_state.StateVectorSimulationState(
available_buffer=np.empty_like(state_vector),
qubits=qubits,
prng=np.random.RandomState(),
initial_state=state_vector.copy(),
dtype=state_vector.dtype,
dtype=complex_dtype,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I misread where this is, this is in the testing of consistent act_on. Think this is fine. Not sure we can assume state_vector dtype is complex, so this works.

@dabacon dabacon added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 7, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 7, 2022
@vtomole
Copy link
Collaborator

vtomole commented Jul 7, 2022

check/mypy --next now passes without errors.

@pavoljuhas How so? I see errors on this PR's mypy --next action: https://github.com/quantumlib/Cirq/runs/7240128717?check_suite_focus=true

@CirqBot CirqBot merged commit 1ca3e95 into quantumlib:master Jul 7, 2022
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jul 7, 2022
@pavoljuhas pavoljuhas deleted the fix-mypy-numpy-errors-4 branch July 7, 2022 19:39
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
- Fix type mismatch in _BufferedStateVector.create argument
- Fix type of the measurements argument to CliffordState.apply_measurement
- Fix type spec of the dtype argument to StateVectorSimulationState

`check/mypy --next` now passes without errors.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
- Fix type mismatch in _BufferedStateVector.create argument
- Fix type of the measurements argument to CliffordState.apply_measurement
- Fix type spec of the dtype argument to StateVectorSimulationState

`check/mypy --next` now passes without errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants