From 56e779d1c72a5ada6c73c92ee3593c505df542e7 Mon Sep 17 00:00:00 2001 From: "Kevin R. Thornton" Date: Mon, 13 Nov 2023 10:35:37 -0800 Subject: [PATCH] check the noise field --- fwdpy11/_types/model_params.py | 6 +++--- tests/test_prune_selected_warning.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/fwdpy11/_types/model_params.py b/fwdpy11/_types/model_params.py index 14155c490..48ef457eb 100644 --- a/fwdpy11/_types/model_params.py +++ b/fwdpy11/_types/model_params.py @@ -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")) diff --git a/tests/test_prune_selected_warning.py b/tests/test_prune_selected_warning.py index 135adbce1..e6cf89b48 100644 --- a/tests/test_prune_selected_warning.py +++ b/tests/test_prune_selected_warning.py @@ -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