Skip to content

Commit 27f2e6f

Browse files
authored
Merge branch 'main' into fix_product
2 parents eb4b4c4 + d194ec5 commit 27f2e6f

32 files changed

Lines changed: 51 additions & 62 deletions

File tree

qualtran/_infra/bloq.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
if TYPE_CHECKING:
3333
import cirq
3434
import networkx as nx
35-
import pennylane as qml
3635
import quimb.tensor as qtn
3736
import sympy
3837
from numpy.typing import NDArray
@@ -41,7 +40,6 @@
4140

4241
from qualtran import (
4342
AddControlledT,
44-
Adjoint,
4543
BloqBuilder,
4644
CompositeBloq,
4745
ConnectionT,

qualtran/_infra/composite_bloq.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,6 @@ def _get_dangling_soquets(signature: Signature, right: bool = True) -> Dict[str,
680680
dang = LeftDangle
681681

682682
all_soqs: Dict[str, SoquetT] = {}
683-
soqs: SoquetT
684683
for reg in regs:
685684
all_soqs[reg.name] = _reg_to_soq(dang, reg)
686685
return all_soqs

qualtran/_infra/quantum_graph_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919

2020

2121
def test_dangling():
22-
assert LeftDangle is LeftDangle
23-
assert RightDangle is RightDangle
22+
assert LeftDangle is LeftDangle # noqa: PLR0124
23+
assert RightDangle is RightDangle # noqa: PLR0124
2424
assert LeftDangle is not RightDangle
2525
assert RightDangle is not LeftDangle
2626

2727
assert isinstance(LeftDangle, DanglingT)
2828
assert isinstance(RightDangle, DanglingT)
2929

30-
assert LeftDangle == LeftDangle
31-
assert RightDangle == RightDangle
30+
assert LeftDangle == LeftDangle # noqa: PLR0124
31+
assert RightDangle == RightDangle # noqa: PLR0124
3232
assert LeftDangle != RightDangle
3333

3434
with pytest.raises(ValueError, match='Do not instantiate.*'):
35-
my_new_dangle = DanglingT('hi mom')
35+
_ = DanglingT('hi mom')
3636

3737

3838
def test_dangling_hash():

qualtran/_infra/registers_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def test_multidim_register():
5555
@pytest.mark.parametrize('n, N, m, M', [(4, 10, 5, 19), (4, 16, 5, 32)])
5656
def test_selection_registers_indexing(n, N, m, M):
5757
dtypes = [BQUInt(n, N), BQUInt(m, M)]
58-
regs = [Register(sym, dtype) for sym, dtype in zip(['x', 'y'], dtypes)]
5958
for x in range(int(dtypes[0].iteration_length)):
6059
for y in range(int(dtypes[1].iteration_length)):
6160
assert np.ravel_multi_index((x, y), (N, M)) == x * M + y

qualtran/bloqs/arithmetic/comparison_test.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,17 @@ def _less_than_equal_expected_t_complexity(gate: LessThanEqual):
202202
# When both registers are of the same size the T complexity is
203203
# 8n - 4 same as in the second reference.
204204
return TComplexity(t=8 * n - 4, clifford=46 * n - 21)
205+
# When the registers differ in size and `n` is the size of the smaller one and
206+
# `d` is the difference in size. The T complexity is the sum of the tree
207+
# decomposition as before giving 8n + O(1) and the T complexity of an `And` gate
208+
# over `d` registers giving 4d + O(1) totaling 8n + 4d + O(1).
209+
# From the decomposition we get that the constant is -4 as well as the clifford counts.
210+
elif d == 1:
211+
return TComplexity(t=8 * n, clifford=46 * n - 1 + 2 * is_second_longer)
205212
else:
206-
# When the registers differ in size and `n` is the size of the smaller one and
207-
# `d` is the difference in size. The T complexity is the sum of the tree
208-
# decomposition as before giving 8n + O(1) and the T complexity of an `And` gate
209-
# over `d` registers giving 4d + O(1) totaling 8n + 4d + O(1).
210-
# From the decomposition we get that the constant is -4 as well as the clifford counts.
211-
if d == 1:
212-
return TComplexity(t=8 * n, clifford=46 * n - 1 + 2 * is_second_longer)
213-
else:
214-
return TComplexity(
215-
t=8 * n + 4 * d - 4, clifford=46 * n + 17 * d - 18 + 2 * is_second_longer
216-
)
213+
return TComplexity(
214+
t=8 * n + 4 * d - 4, clifford=46 * n + 17 * d - 18 + 2 * is_second_longer
215+
)
217216

218217

219218
@pytest.mark.parametrize("x_bitsize", [*range(1, 5)])
@@ -302,7 +301,7 @@ def test_greater_than_constant():
302301
q0 = bb.add_register('x', bitsize)
303302
anc = bb.add_register('result', 1)
304303
q0, anc = bb.add(GreaterThanConstant(bitsize, 17), x=q0, target=anc)
305-
cbloq = bb.finalize(x=q0, result=anc)
304+
bb.finalize(x=q0, result=anc)
306305
qlt_testing.assert_wire_symbols_match_expected(
307306
GreaterThanConstant(bitsize, 17), ['In(x)', '⨁(x > 17)']
308307
)

qualtran/bloqs/arithmetic/controlled_addition.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from qualtran.symbolics.types import is_symbolic
4444

4545
if TYPE_CHECKING:
46-
import quimb.tensor as qtn
4746

4847
from qualtran.drawing import WireSymbol
4948
from qualtran.resource_counting import BloqCountDictT, SympySymbolAllocator

qualtran/bloqs/arithmetic/permutation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
from qualtran.symbolics import bit_length, is_symbolic, Shaped, slen, SymbolicInt
5050

5151
if TYPE_CHECKING:
52-
import sympy
5352

5453
from qualtran import BloqBuilder, SoquetT
5554
from qualtran.resource_counting import BloqCountDictT, BloqCountT, SympySymbolAllocator

qualtran/bloqs/basic_gates/rotation_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def test_t_like_rotation_gates():
174174
[Rx(0.01), Ry(0.01), Rz(0.01), ZPowGate(0.01), YPowGate(0.01), XPowGate(0.01), CZPowGate(0.01)],
175175
)
176176
def test_rotation_gates_adjoint(bloq):
177-
assert type(bloq) == type(bloq.adjoint())
177+
assert type(bloq) == type(bloq.adjoint()) # noqa: E721
178178
np.testing.assert_allclose(
179179
bloq.tensor_contract() @ bloq.adjoint().tensor_contract(),
180180
np.identity(2 ** bloq.signature.n_qubits()),

qualtran/bloqs/block_encoding/linear_combination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
SoquetT,
3636
)
3737
from qualtran.bloqs.block_encoding import BlockEncoding
38-
from qualtran.bloqs.block_encoding.lcu_block_encoding import BlackBoxPrepare, BlackBoxSelect
3938
from qualtran.bloqs.block_encoding.phase import Phase
4039
from qualtran.bloqs.bookkeeping.auto_partition import AutoPartition, Unused
4140
from qualtran.bloqs.bookkeeping.partition import Partition
41+
from qualtran.bloqs.multiplexers.black_box_select import BlackBoxSelect
4242
from qualtran.bloqs.reflections.prepare_identity import PrepareIdentity
4343
from qualtran.bloqs.state_preparation.black_box_prepare import BlackBoxPrepare
4444
from qualtran.linalg.lcu_util import preprocess_probabilities_for_reversible_sampling

qualtran/bloqs/bookkeeping/allocate_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_free_nonzero_state_vector_leads_to_unnormalized_state():
3232
bb = BloqBuilder()
3333
qs1 = bb.add(Allocate(QAny(10)))
3434
qs2 = bb.add(OnEach(10, Hadamard()), q=qs1)
35-
no_return = bb.add(Free(QAny(10)), reg=qs2)
35+
_no_return = bb.add(Free(QAny(10)), reg=qs2)
3636
assert np.allclose(bb.finalize().tensor_contract(), np.sqrt(1 / 2**10))
3737

3838

0 commit comments

Comments
 (0)