about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2025-08-04 12:31:24 +0100
committerArun Isaac2025-08-06 22:35:26 +0100
commit2dc2efa7f77deb5ebcf7b80abefc162474614b2c (patch)
tree2fdb75e3de75dcdf461f8fde133fc3b338313f80
parent5c086aa352012cf95b33cab8e506424016b28a26 (diff)
downloadpyhegp-2dc2efa7f77deb5ebcf7b80abefc162474614b2c.tar.gz
pyhegp-2dc2efa7f77deb5ebcf7b80abefc162474614b2c.tar.lz
pyhegp-2dc2efa7f77deb5ebcf7b80abefc162474614b2c.zip
Move negate to pyhegp.utils.
* tests/test_pyhegp.py (negate): Move to pyhegp.utils.
Import negate from pyhegp.utils.
* pyhegp/utils.py: New file.
-rw-r--r--pyhegp/utils.py20
-rw-r--r--tests/test_pyhegp.py4
2 files changed, 21 insertions, 3 deletions
diff --git a/pyhegp/utils.py b/pyhegp/utils.py
new file mode 100644
index 0000000..8bb7121
--- /dev/null
+++ b/pyhegp/utils.py
@@ -0,0 +1,20 @@
+### 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/>.
+
+def negate(predicate):
+    return lambda *args, **kwargs: not predicate(*args, **kwargs)
diff --git a/tests/test_pyhegp.py b/tests/test_pyhegp.py
index c355df5..1fceb99 100644
--- a/tests/test_pyhegp.py
+++ b/tests/test_pyhegp.py
@@ -24,6 +24,7 @@ import numpy as np
 from pytest import approx
 
 from pyhegp.pyhegp import Stats, hegp_encrypt, hegp_decrypt, random_key, pool_stats, standardize, unstandardize
+from pyhegp.utils import negate
 
 @given(st.lists(st.lists(arrays("float64",
                                 st.shared(array_shapes(min_dims=1, max_dims=1),
@@ -81,9 +82,6 @@ def square_matrices(order, elements=None):
         return draw(arrays("float64", (n, n), elements=elements))
     return st.composite(generate)
 
-def negate(predicate):
-    return lambda *args, **kwargs: not predicate(*args, **kwargs)
-
 def is_singular(matrix):
     # We want to avoid nearly singular matrices as well. Hence, we set
     # a looser absolute tolerance.