about summary refs log tree commit diff
path: root/tests/test_pyhegp.py
diff options
context:
space:
mode:
authorArun Isaac2026-01-15 02:57:02 +0000
committerArun Isaac2026-01-16 23:06:38 +0000
commit1a907c0b75080891a960e561bcca5d7a35624cac (patch)
treedfe5545446b31e3cc1939a8bb9991a33c9bb86a4 /tests/test_pyhegp.py
parentc3fa476d8312ee74d789b9febe75136fb29392a6 (diff)
downloadpyhegp-1a907c0b75080891a960e561bcca5d7a35624cac.tar.gz
pyhegp-1a907c0b75080891a960e561bcca5d7a35624cac.tar.lz
pyhegp-1a907c0b75080891a960e561bcca5d7a35624cac.zip
Separate centering from normalization.
Diffstat (limited to 'tests/test_pyhegp.py')
-rw-r--r--tests/test_pyhegp.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/test_pyhegp.py b/tests/test_pyhegp.py
index cdf3a7f..c3cf47f 100644
--- a/tests/test_pyhegp.py
+++ b/tests/test_pyhegp.py
@@ -1,5 +1,5 @@
 ### pyhegp --- Homomorphic encryption of genotypes and phenotypes
-### Copyright © 2025 Arun Isaac <arunisaac@systemreboot.net>
+### Copyright © 2025–2026 Arun Isaac <arunisaac@systemreboot.net>
 ###
 ### This file is part of pyhegp.
 ###
@@ -29,7 +29,7 @@ import pandas as pd
 import pytest
 from pytest import approx
 
-from pyhegp.pyhegp import Stats, main, hegp_encrypt, hegp_decrypt, random_key, pool_stats, standardize, unstandardize, genotype_summary, encrypt_genotype, encrypt_phenotype, cat_genotype, cat_phenotype
+from pyhegp.pyhegp import Stats, main, hegp_encrypt, hegp_decrypt, random_key, pool_stats, center, uncenter, standardize, unstandardize, genotype_summary, encrypt_genotype, encrypt_phenotype, cat_genotype, cat_phenotype
 from pyhegp.serialization import Summary, read_summary, read_genotype, is_genotype_metadata_column, is_phenotype_metadata_column
 from pyhegp.utils import negate
 
@@ -95,6 +95,13 @@ def test_hegp_encryption_decryption_are_inverses(plaintext):
 
 @given(arrays("float64",
               array_shapes(min_dims=2, max_dims=2),
+              elements=st.floats(min_value=0, max_value=100)))
+def test_center_uncenter_are_inverses(matrix):
+    mean = np.mean(matrix, axis=0)
+    assert uncenter(center(matrix, mean), mean) == approx(matrix)
+
+@given(arrays("float64",
+              array_shapes(min_dims=2, max_dims=2),
               elements=st.floats(min_value=0, max_value=100))
        # Reject matrices with zero standard deviation columns since
        # they trigger a division by zero.