aboutsummaryrefslogtreecommitdiff
path: root/test_pyhegp.py
diff options
context:
space:
mode:
authorArun Isaac2025-07-08 16:14:00 +0100
committerArun Isaac2025-07-17 01:47:44 +0100
commita6bf9abb91ad6576ce23e7f8731e74c2a73d2ea6 (patch)
treec2e97040871cb4f779a1a59687565995bd1b3a80 /test_pyhegp.py
parent2829c4311d0c21d983621ce8b2c5565ddbc5dbf4 (diff)
downloadpyhegp-a6bf9abb91ad6576ce23e7f8731e74c2a73d2ea6.tar.gz
pyhegp-a6bf9abb91ad6576ce23e7f8731e74c2a73d2ea6.tar.lz
pyhegp-a6bf9abb91ad6576ce23e7f8731e74c2a73d2ea6.zip
Organize source into directory structure.
* pyhegp/__init__.py: New file. * pyhegp.py: Move to pyhegp/pyhegp.py. * test_pyhegp.py: Move to tests/test_pyhegp.py. Import from pyhegp.pyhegp instead of from pyhegp. * pyproject.toml (project.scripts)[pyhegp]: Switch to pyhegp.pyhegp:main.
Diffstat (limited to 'test_pyhegp.py')
-rw-r--r--test_pyhegp.py45
1 files changed, 0 insertions, 45 deletions
diff --git a/test_pyhegp.py b/test_pyhegp.py
deleted file mode 100644
index 19e58d2..0000000
--- a/test_pyhegp.py
+++ /dev/null
@@ -1,45 +0,0 @@
-### pyhegp --- Homomorphic encryption of genotypes and phenotypes
-### Copyright © 2025 Arun Isaac <arunisaac@systemreboot.net>
-###
-### This file is part of pyhegp.
-###
-### pyhegp is free software: you can redistribute it and/or modify it
-### under the terms of the GNU General Public License as published by
-### the Free Software Foundation, either version 3 of the License, or
-### (at your option) any later version.
-###
-### pyhegp is distributed in the hope that it will be useful, but
-### WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-### General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with pyhegp. If not, see <https://www.gnu.org/licenses/>.
-
-from hypothesis import given, settings, strategies as st
-from hypothesis.extra.numpy import arrays, array_shapes
-import numpy as np
-from pytest import approx
-
-from pyhegp import hegp_encrypt, hegp_decrypt, random_key
-
-@given(st.one_of(
- arrays("int32",
- array_shapes(min_dims=2, max_dims=2, min_side=2, max_side=200),
- elements=st.integers(min_value=0, max_value=2)),
- # The array above is the only realistic input, but we test more
- # kinds of inputs for good measure.
- arrays("int32",
- array_shapes(min_dims=2, max_dims=2, min_side=2, max_side=200),
- elements=st.integers(min_value=0, max_value=100)),
- arrays("float64",
- array_shapes(min_dims=2, max_dims=2, min_side=2, max_side=200),
- elements=st.floats(min_value=0, max_value=100)))
-)
-@settings(deadline=None)
-def test_hegp_encryption_decryption_are_inverses(plaintext):
- rng = np.random.default_rng()
- key = random_key(rng, len(plaintext))
- # FIXME: We don't use maf at the moment.
- maf = None
- assert hegp_decrypt(hegp_encrypt(plaintext, maf, key), key) == approx(plaintext)