Skip to content

Commit

Permalink
check the noise field
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Nov 13, 2023
1 parent 4a87ada commit 56e779d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fwdpy11/_types/model_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ def _is_multiplicative(self, gvalue):
if not isinstance(self.gvalue, fwdpy11.Multiplicative):
multiplicative = False
if gvalue.gvalue_to_fitness is not None:
if not isinstance(
gvalue.gvalue_to_fitness, fwdpy11.GeneticValueIsFitness
):
if not isinstance(gvalue.gvalue_to_fitness, fwdpy11.GeneticValueIsFitness):
multiplicative = False
if gvalue.noise is not None and not isinstance(gvalue.noise, fwdpy11.NoNoise):
multiplicative = False

if not multiplicative and self.prune_selected is True:
warnings.warn(fwdpy11.PruneSelectedWarning("foo"))
Expand Down
14 changes: 14 additions & 0 deletions tests/test_prune_selected_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,17 @@ def test_multiplicative_fitness_model():
assert params.prune_selected is True
except fwdpy11.PruneSelectedWarning as e:
pytest.fail(f"unexpected exception {e}")


def test_multiplicative_fitness_model_with_noise():
pdict = {
"gvalue": fwdpy11.Multiplicative(
scaling=2.0, noise=fwdpy11.GaussianNoise(mean=1.0, sd=1.0)
),
"rates": (0, 0, 0),
"demography": fwdpy11.ForwardDemesGraph.tubes([100], burnin=1),
"simlen": 100,
}
with pytest.warns(fwdpy11.PruneSelectedWarning):
params = fwdpy11.ModelParams(**pdict)
assert params.prune_selected is True

0 comments on commit 56e779d

Please sign in to comment.