Skip to content

Commit

Permalink
more reasonable tests, remove leftover condition
Browse files Browse the repository at this point in the history
  • Loading branch information
gilcu3 committed May 12, 2024
1 parent 4be0965 commit 1900094
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions discretelog/linear_sieve_index_calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def sieve_values(self, n, DEBUG=False):
yield c2, c1, fn

def sieve_values_parallel(self, n, DEBUG):
if True or (self.c2 + n) <= 1000 or cpu_count() <= 1:
if (self.c2 + n) <= 1000 or cpu_count() <= 1:
yield from self.sieve_values(n, DEBUG)
return
rng = range(self.c2, self.c2 + n)
Expand Down Expand Up @@ -463,7 +463,7 @@ def linear_sieve_dlog(p, gy, y, op=None, qlimit=None, climit=None, DEBUG=False):
op = order(gy, p)
assert isprime(op)
assert (p - 1) % op == 0
assert op >= 10 ** 5
assert op >= 10 ** 6
assert order(gy, p) == op
opq = op
while (p - 1) % (opq * op) == 0:
Expand Down Expand Up @@ -515,7 +515,7 @@ def linear_sieve_dlog(p, gy, y, op=None, qlimit=None, climit=None, DEBUG=False):
if DEBUG:
print('solution not converging, trying higher qlimit')
return linear_sieve_dlog(p, gy, y, op, qlimit+50, climit, DEBUG)
nclimit = climit if first else max(50,climit//10)
nclimit = climit if first else max(50, climit // 10)
if DEBUG:
print(f'\nSolving: p={p} gy={gy} y={y} fbp={len(fbq)}',
f'qlimit={qlimit}',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ def test_factor_large(frandom):
+ Fore.RESET + '\n')
for d in mrange(30, 100, 10, True):
single_test_factor_random(d, frandom)
for d in mrange(30, 60, 10, True):
for d in mrange(30, 40, 1, True):
single_test_factor_rsa(d, frandom)
4 changes: 2 additions & 2 deletions tests/test_discretelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def single_test_random(nb, random):


def test_dlog_small(frandom):
ntests = 200
ntests = 1000
print('\n' + Fore.RED + 'Testing small values' + Fore.RESET + '\n')
for nb in mrange(5, 30, 1, True):
for _ in range(ntests):
Expand All @@ -30,7 +30,7 @@ def test_dlog_small(frandom):

def test_dlog_medium(frandom):
print('\n' + Fore.RED + 'Testing medium values' + Fore.RESET + '\n')
for nb in mrange(30, 60, 2, True):
for nb in mrange(30, 60, 1, True):
single_test_random(nb, frandom)


Expand Down
10 changes: 5 additions & 5 deletions tests/test_linear_sieve_index_calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@ def test_special(frandom):


def test_linear_sieve_dlog_small(frandom):
ntests = 200
ntests = 500
print('sophie germaine primes')
for psize in range(5, 9):
for psize in range(6, 9):
print(f'psize={psize}')
for _ in mrange(ntests, DEBUG=True):
single_test(psize, frandom)


def test_linear_sieve_dlog_medium(frandom):
ntests = 20
ntests = 100
print('sophie germaine primes')
for psize in range(9, 14):
print(f'psize={psize}')
for _ in mrange(ntests, DEBUG=True):
single_test(psize, frandom)
ntests = 20
ntests = 100
print('higher order')
for _ in mrange(ntests, DEBUG=True):
higher_order_test(5, frandom)
higher_order_test(6, frandom)


@pytest.mark.slow
Expand Down

0 comments on commit 1900094

Please sign in to comment.