MCPcopy Create free account
hub / github.com/OpenMined/TenSEAL / test_modulus

Function test_modulus

tests/python/sealapi/test_modulus.py:9–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8
9def test_modulus():
10 testcase = sealapi.Modulus(1023)
11 assert testcase.bit_count() == 10
12 assert testcase.uint64_count() == 1
13 assert testcase.value() == 1023
14 assert testcase.data() == 1023
15 assert testcase.const_ratio()[2] == (2**128) % 1023
16 assert not testcase.is_zero()
17 assert not testcase.is_prime()
18
19 def save_load(path):
20 testcase.save(path)
21 save_test = sealapi.Modulus(0)
22 save_test.load(path)
23 assert save_test.value() == 1023
24
25 tmp_file(save_load)
26
27 testcase = sealapi.Modulus(15451)
28 assert testcase.is_prime()
29
30 testcase = sealapi.Modulus(0)
31 assert testcase.is_zero()
32
33 # operators
34 start = 15451
35 left = sealapi.Modulus(start)
36 right = sealapi.Modulus(start)
37 assert left == right
38 assert left == start
39
40 right = sealapi.Modulus(start + 1)
41 assert left != right
42 assert right != start
43 assert left < right
44 assert left < start + 1
45 assert left <= right
46 assert left <= start
47 assert left <= start + 1
48
49 right = sealapi.Modulus(start - 1)
50 assert left > right
51 assert left > start - 1
52 assert left >= right
53 assert left >= start
54 assert left >= start - 1
55
56
57@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 2

tmp_fileFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected