Skip to content

Commit

Permalink
test for sim_2d_patefield
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Urlus authored and Ralph Urlus committed Mar 29, 2021
1 parent 9ca8f68 commit 11f850d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/phik_python/test_phik.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ def test_simulation_2d_patefield(self):
"""Test simulation code using patefield algorithm."""
import numpy as np
from phik.simulation import sim_2d_data_patefield
o_seed = np.random.get_state()
og_state = np.random.get_state()
np.random.seed(42)
test_data = np.random.randint(1, 100, (20, 2))
res = sim_2d_data_patefield(test_data)

self.assertTrue(np.isclose(res, ref))

# reset seed
np.random.seed(o_seed)

sample = np.random.randint(1, 200, (50, 2))

# call test function
res = sim_2d_data_patefield(sample, seed=42)
np.random.set_state(og_state)
mean0, mean1 = res.mean(1)
self.assertTrue(np.isclose(mean0, 105.46))
self.assertTrue(np.isclose(mean1, 91.18))

0 comments on commit 11f850d

Please sign in to comment.