Skip to content

Use np.complexfloating for dtypes that should be complex#5488

Merged
CirqBot merged 12 commits intoquantumlib:masterfrom
dabacon:diemypydie
Jun 23, 2022
Merged

Use np.complexfloating for dtypes that should be complex#5488
CirqBot merged 12 commits intoquantumlib:masterfrom
dabacon:diemypydie

Conversation

@dabacon
Copy link
Copy Markdown
Collaborator

@dabacon dabacon commented Jun 11, 2022

This changes the type signature for dtypes that should only be np.complex64 or np.complex128.

There are also dtypes in qis.states.py but I've not changed these over, as they are often called the dtype of a np.array, and so they will often need to be cast.

This fixes some check/mypy --next errors.

Technically a breaking change in type signature (more restrictive), but we yell when types are not complex.

@dabacon dabacon requested review from a team, cduck and vtomole as code owners June 11, 2022 15:38
@dabacon dabacon requested a review from MichaelBroughton June 11, 2022 15:38
@CirqBot CirqBot added the size: M 50< lines changed <250 label Jun 11, 2022
@dabacon dabacon added the kind/health For CI/testing/release process/refactoring/technical debt items label Jun 11, 2022
@dabacon
Copy link
Copy Markdown
Collaborator Author

dabacon commented Jun 15, 2022

#3767

Copy link
Copy Markdown
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

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

cool. much better type info

prng=mock_prng,
initial_state=np.copy(state),
dtype=state.dtype,
dtype=cast(Type[np.complexfloating], state.dtype),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can change this cast to an assert earlier?

@dabacon dabacon added the BREAKING CHANGE For pull requests that are important to mention in release notes. label Jun 22, 2022
@dabacon dabacon added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jun 23, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jun 23, 2022
@CirqBot CirqBot merged commit 3c8b036 into quantumlib:master Jun 23, 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 Jun 23, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…5488)

This changes the type signature for dtypes that should only be `np.complex64` or `np.complex128`.

There are also dtypes in `qis.states.py` but I've not changed these over, as they are often called the `dtype` of a `np.array`, and so they will often need to be cast.

This fixes some `check/mypy --next` errors.

Technically a breaking change in type signature (more restrictive), but we yell when types are not complex.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
…5488)

This changes the type signature for dtypes that should only be `np.complex64` or `np.complex128`.

There are also dtypes in `qis.states.py` but I've not changed these over, as they are often called the `dtype` of a `np.array`, and so they will often need to be cast.

This fixes some `check/mypy --next` errors.

Technically a breaking change in type signature (more restrictive), but we yell when types are not complex.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BREAKING CHANGE For pull requests that are important to mention in release notes. kind/health For CI/testing/release process/refactoring/technical debt items size: M 50< lines changed <250

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants