From 654c5a89a4f3e2fc09b289a8b6e9a056a20488b8 Mon Sep 17 00:00:00 2001 From: Tom Hodson Date: Wed, 1 Jun 2022 13:18:25 +0200 Subject: [PATCH] add tests using hypothesis --- code/tests/test_energy_using_hypothesis.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 code/tests/test_energy_using_hypothesis.py diff --git a/code/tests/test_energy_using_hypothesis.py b/code/tests/test_energy_using_hypothesis.py new file mode 100644 index 0000000..ecef640 --- /dev/null +++ b/code/tests/test_energy_using_hypothesis.py @@ -0,0 +1,12 @@ +import numpy as np +from hypothesis import given +from hypothesis import strategies as st +from hypothesis.extra import numpy as hnp + +from MCFF.ising_model import energy, energy_numpy + +@given(hnp.arrays(dtype = int, + shape = hnp.array_shapes(min_dims = 2, max_dims = 2), + elements = st.sampled_from([1, -1]))) +def test_generated_states(state): + assert np.allclose(energy(state), energy_numpy(state)) \ No newline at end of file