mirror of
https://github.com/ImperialCollegeLondon/ReCoDE_MCMCFF.git
synced 2025-06-26 08:51:16 +02:00
add tests using hypothesis
This commit is contained in:
parent
aea9e06309
commit
654c5a89a4
12
code/tests/test_energy_using_hypothesis.py
Normal file
12
code/tests/test_energy_using_hypothesis.py
Normal file
@ -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))
|
Loading…
x
Reference in New Issue
Block a user