Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fpapa250 committed Nov 2, 2024
1 parent 42cd677 commit 3fd1b22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
10 changes: 3 additions & 7 deletions qualtran/bloqs/factoring/ecc/ec_add_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ def test_ec_add_symbolic_cost():
b = ECAdd(n=4 * m, window_size=4, mod=p)
cost = get_cost_value(b, QECGatesCost()).total_t_and_ccz_count()
# We have some T gates since we use CSwapApprox instead of n CSWAPs in KaliskiModInverse.
total_toff = (cost['n_t'] / 4 + cost['n_ccz'].subs(m, n / 4)) * sympy.Integer(1)
total_toff = total_toff.expand()
total_toff = (cost['n_t'] / 4 + cost['n_ccz']) * sympy.Integer(1)
total_toff = total_toff.subs(m, n / 4).expand()

# Litinski 2023 https://arxiv.org/abs/2306.08585
# Based on the counts from Figures 3, 5, and 8 the toffoli count for ECAdd is 126.5n^2 + 189n.
Expand All @@ -418,11 +418,7 @@ def test_ec_add_symbolic_cost():
# toffoli cost for Kaliski Mod Inverse, n extra toffolis in ModNeg, 2n extra toffolis to do n
# 3-controlled toffolis in step 2. The expression is written with rationals because sympy
# comparison fails with floats.
assert isinstance(cost['n_ccz'], sympy.Expr)
assert (
total_toff.subs(m, n / 4).expand()
== sympy.Rational(253, 2) * n**2 + sympy.Rational(391, 2) * n - 31
)
assert total_toff == sympy.Rational(253, 2) * n**2 + sympy.Rational(391, 2) * n - 31


def test_ec_add(bloq_autotester):
Expand Down
8 changes: 4 additions & 4 deletions qualtran/bloqs/mod_arithmetic/mod_division.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,10 @@ def on_classical_vals(self, x: int, m: int = 0) -> Dict[str, 'ClassicalValT']:
for _ in range(2 * int(self.bitsize)):
u, v, r, s, m_i, f = iteration.call_classically(u=u, v=v, r=r, s=s, m=0, f=f)
m = (m << 1) | m_i
#assert u == 1
#assert s == self.mod
#assert f == 0
#assert v == 0
# assert u == 1
# assert s == self.mod
# assert f == 0
# assert v == 0
return {'x': self.mod - r, 'm': m}


Expand Down

0 comments on commit 3fd1b22

Please sign in to comment.