Skip to content

Commit

Permalink
[tests] Adjust tests for 'report_seed'
Browse files Browse the repository at this point in the history
  • Loading branch information
jofmi committed Sep 16, 2021
1 parent 969f49c commit 7db9489
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
13 changes: 3 additions & 10 deletions tests/test_datadict.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,11 @@ def test_combine_vars():
results = model.run(1, display=False)
assert results._combine_pars(constants=False) is None

#results.variables = 1
#with pytest.raises(TypeError):
# assert results._combine_vars()
#results.parameters = 1
#with pytest.raises(TypeError):
# assert results._combine_pars()


repr = """DataDict {
'info': Dictionary with 12 keys
'parameters':
'constants': Dictionary with 1 key
'constants': Dictionary with 2 keys
'sample': DataFrame with 1 variable and 10 rows
'log': Dictionary with 3 keys
'variables':
Expand All @@ -85,7 +78,7 @@ def step(self):


def test_repr():
param_ranges = {'x': ap.Range(0., 1.), 'y': 1}
param_ranges = {'x': ap.Range(0., 1.), 'y': 1, 'report_seed': False}
sample = ap.Sample(param_ranges, n=10)
results = ap.Experiment(MyModel, sample, record=True).run()
assert results.__repr__() == repr
Expand Down Expand Up @@ -146,7 +139,7 @@ def end(self):

def test_testing_model():

parameters = {'steps': 2, 'px': ap.Values(1, 2)}
parameters = {'steps': 2, 'px': ap.Values(1, 2), 'report_seed': False}
sample = ap.Sample(parameters)
settings = {'iterations': 2,
'record': True}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def test_basics():

def test_parallel_processing():

exp = ap.Experiment(MyModel, [{'steps': 1}] * 3)
exp = ap.Experiment(MyModel, [{'steps': 1, 'report_seed': False}] * 3)
pool = mp.Pool(mp.cpu_count())
results = exp.run(pool)

exp2 = ap.Experiment(MyModel, [{'steps': 1}] * 3)
exp2 = ap.Experiment(MyModel, [{'steps': 1, 'report_seed': False}] * 3)
results2 = exp2.run()

del results.info
Expand Down
4 changes: 2 additions & 2 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def setup(self, y):
self.report('y', y)
self.stop()

parameters = {'x': 1}
parameters = {'x': 1, 'report_seed': False}
model = MyModel(parameters, y=2)
model.run(display=False)
assert model.reporters == {'x': 1, 'y': 2}
model_func = MyModel.as_function(y=2)
assert model_func(x=1) == {'x': 1, 'y': 2}
assert model_func(x=1, report_seed=False) == {'x': 1, 'y': 2}


def test_update_parameters():
Expand Down

0 comments on commit 7db9489

Please sign in to comment.