Skip to content

Do not allow creating registers with bitsize 0#6298

Merged
tanujkhattar merged 2 commits intoquantumlib:masterfrom
tanujkhattar:non_zero_bitsize
Sep 25, 2023
Merged

Do not allow creating registers with bitsize 0#6298
tanujkhattar merged 2 commits intoquantumlib:masterfrom
tanujkhattar:non_zero_bitsize

Conversation

@tanujkhattar
Copy link
Copy Markdown
Collaborator

Registers with bitsize 0 are ambiguous since they you are not really passing any qubits to instantiate those registers. They also complicate the interop with Qualtran. This PR removes this workflow by adding an explicit validation that bitsize should always be a positive integer.

cc @mpharrigan

@tanujkhattar tanujkhattar requested review from a team and cduck as code owners September 21, 2023 22:46
@tanujkhattar tanujkhattar requested a review from maffoo September 21, 2023 22:46
@CirqBot CirqBot added the size: S 10< lines changed <50 label Sep 21, 2023
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 21, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (8e4e7d1) 97.88% compared to head (a63eee2) 97.88%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6298   +/-   ##
=======================================
  Coverage   97.88%   97.88%           
=======================================
  Files        1104     1104           
  Lines       95863    95869    +6     
=======================================
+ Hits        93840    93846    +6     
  Misses       2023     2023           
Files Changed Coverage Δ
cirq-ft/cirq_ft/algos/and_gate.py 100.00% <100.00%> (ø)
cirq-ft/cirq_ft/algos/apply_gate_to_lth_target.py 100.00% <100.00%> (ø)
...-ft/cirq_ft/algos/prepare_uniform_superposition.py 100.00% <100.00%> (ø)
cirq-ft/cirq_ft/algos/qrom.py 100.00% <100.00%> (ø)
cirq-ft/cirq_ft/algos/selected_majorana_fermion.py 100.00% <100.00%> (ø)
cirq-ft/cirq_ft/algos/state_preparation.py 100.00% <100.00%> (ø)
cirq-ft/cirq_ft/infra/gate_with_registers.py 96.32% <100.00%> (+0.11%) ⬆️
cirq-ft/cirq_ft/infra/gate_with_registers_test.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cached_property
def target_registers(self) -> Tuple[infra.Register, ...]:
total_iteration_size = np.product(
total_iteration_size = np.prod(
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.

for my edification: why this change?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It fails mypy checks because np.product has been deprecated.

@tanujkhattar tanujkhattar merged commit acbc624 into quantumlib:master Sep 25, 2023
@tanujkhattar tanujkhattar added the area/cirq-ft Issues related to the Cirq-FT sub-package label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cirq-ft Issues related to the Cirq-FT sub-package size: S 10< lines changed <50

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants