about summary refs log tree commit diff
path: root/tests/test_serialization.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_serialization.py')
-rw-r--r--tests/test_serialization.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/test_serialization.py b/tests/test_serialization.py
index 15de278..a473796 100644
--- a/tests/test_serialization.py
+++ b/tests/test_serialization.py
@@ -19,10 +19,12 @@
 import tempfile
 
 from hypothesis import given, strategies as st
+from hypothesis.extra.numpy import arrays, array_shapes
 from hypothesis.extra.pandas import column, columns, data_frames
 import pandas as pd
+from pytest import approx
 
-from pyhegp.serialization import Summary, read_summary, write_summary, read_summary_headers, read_genotype, write_genotype
+from pyhegp.serialization import Summary, read_summary, write_summary, read_summary_headers, read_genotype, write_genotype, read_key, write_key
 from pyhegp.utils import negate
 
 tabless_printable_ascii_text = st.text(
@@ -115,3 +117,11 @@ def test_read_write_genotype_are_inverses(genotype):
         write_genotype(file, genotype)
         file.seek(0)
         pd.testing.assert_frame_equal(genotype, read_genotype(file))
+
+@given(arrays("float64",
+              array_shapes(min_dims=2, max_dims=2)))
+def test_read_write_key_are_inverses(key):
+    with tempfile.TemporaryFile() as file:
+        write_key(file, key)
+        file.seek(0)
+        assert key == approx(read_key(file), nan_ok=True)