File: test_random.py

package info (click to toggle)
fpylll 0.6.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,064 kB
  • sloc: python: 2,193; makefile: 172; sh: 89; ansic: 79; cpp: 48
file content (27 lines) | stat: -rw-r--r-- 645 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-

from cysignals.signals import SignalError
from pytest import raises

from fpylll import IntegerMatrix, FPLLL


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)
    return A


def test_zero_bits():
    with raises(SignalError):
        IntegerMatrix.random(10, "qary", k=5, bits=0)


def test_randomize():
    FPLLL.set_random_seed(1337)
    A0 = make_integer_matrix(20, 20)
    FPLLL.set_random_seed(1337)
    A1 = make_integer_matrix(20, 20)
    for i in range(20):
        for j in range(20):
            assert A0[i, j] == A1[i, j]