Skip to content

Commit

Permalink
ship tests/tools.py
Browse files Browse the repository at this point in the history
  • Loading branch information
malb committed Dec 11, 2020
1 parent b291a5a commit 91b687a
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
run: pip install flake8

- name: Flake8
run: flake8 --max-line-length=120 --max-complexity=16 --ignore=E22,E241,E741,E203 src
run: flake8 --max-line-length=120 --max-complexity=16 --ignore=E22,E241,E741,E203 src tests

1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ global-include README.rst requirements.txt suggestions.txt
global-include setup.py *.pyx
graft src
include tests/test_*
include tests/tools.py
include LICENSE
prune build
prune dist
4 changes: 2 additions & 2 deletions tests/test_bkz.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def test_bkz_bkz():
for i in range(1, len(b00)):
assert b00[0] == b00[i]


def test_bkz_gram_bkz_coherence():
"""
Test if BKZ is coherent if it is given a matrix A or its associated
Expand All @@ -68,12 +69,11 @@ def test_bkz_gram_bkz_coherence():
param = BKZ.Param(block_size=min(m, 40), strategies=BKZ.DEFAULT_STRATEGY)
bkz_a = BKZ.Reduction(GSO_A, lll_obj_a, param)
bkz_g = BKZ.Reduction(GSO_G, lll_obj_g, param)

bkz_a()
bkz_g()

G_updated = tools.compute_gram(A)
for i in range(m):
for j in range(i + 1):
assert G_updated[i, j] == G[i, j]

3 changes: 2 additions & 1 deletion tests/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import tools


def make_integer_matrix(m, n, int_type="mpz"):
A = IntegerMatrix(m, n, int_type=int_type)
A.randomize("qary", k=m // 2, bits=m)
Expand Down Expand Up @@ -34,7 +35,7 @@ def test_enum_enum():
def test_enum_gram_coherence():
"""
Test if the enumeration algorithm is consistent with the Gram matrices
The vectors returned by the enumeration should be the same wether a
The vectors returned by the enumeration should be the same wether a
lattice is given by its basis or by its Gram matrix
"""

Expand Down
7 changes: 3 additions & 4 deletions tests/test_gso.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def test_gso_io():
v_ = list(v_[0])
assert v == v_


def test_gso_coherence_gram_matrix():
"""
Test if the GSO is coherent if it is given a matrix A or its associated
Expand Down Expand Up @@ -152,10 +153,8 @@ def test_gso_coherence_gram_matrix():

for j in range(i):
assert (
M_A.get_r(i, j) ==
pytest.approx(M_G.get_r(i, j), rel=EPSILON)
M_A.get_r(i, j) == pytest.approx(M_G.get_r(i, j), rel=EPSILON)
)
assert (
M_A.get_mu(i, j) ==
pytest.approx(M_G.get_mu(i, j), rel=EPSILON)
M_A.get_mu(i, j) == pytest.approx(M_G.get_mu(i, j), rel=EPSILON)
)
1 change: 0 additions & 1 deletion tests/test_lll.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,3 @@ def test_lll_gram_lll_coherence():
for i in range(m):
for j in range(i + 1):
assert G_updated[i, j] == G[i, j]

2 changes: 1 addition & 1 deletion tests/test_pruner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fpylll import Enumeration, GSO, IntegerMatrix, LLL, Pruning
from fpylll.util import gaussian_heuristic
try:
from time import process_time # Python 3
from time import process_time # Python 3
except ImportError:
from time import clock as process_time # Python 2

Expand Down
1 change: 1 addition & 0 deletions tests/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from copy import copy


def compute_gram(B):
"""
Compute the Gram matrix of the row-lattice with basis B
Expand Down

0 comments on commit 91b687a

Please sign in to comment.