Skip to content

Commit

Permalink
Deprecate use of None for a demographic model.
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Nov 9, 2023
1 parent 22b2cbb commit 715db96
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions fwdpy11/_evolvets.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ def evolvets(
sizes = pop.deme_sizes()[1].tolist()
msg = "Applying a default demographic model "
msg += f"where deme sizes are {sizes} "
msg += f"and the burn-in length is 10*{sum(sizes)}"
warnings.warn(msg, stacklevel=2)
msg += f"and the burn-in length is 10*{sum(sizes)}. "
msg += "This will raise an error in future releases."
warnings.warn(msg, DeprecationWarning, stacklevel=2)
demographic_model = ForwardDemesGraph.tubes(sizes, 10)

for r in params.sregions:
Expand Down
8 changes: 5 additions & 3 deletions fwdpy11/_types/model_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ class ModelParams(object):
recregions = attr.ib(factory=list)
rates: MutationAndRecombinationRates = attr.ib(converter=_convert_rates)
gvalue = attr.ib(default=None)
demography: typing.Optional[typing.Union[ForwardDemesGraph,
DemographicModelDetails]] = attr.ib(
default=None)
demography: typing.Union[ForwardDemesGraph,
DemographicModelDetails] = attr.ib(default=None)
simlen: int = attr.ib(converter=int, default=0)
prune_selected: bool = attr.ib(default=True)
allow_residual_selfing: bool = attr.ib(default=True)
Expand Down Expand Up @@ -290,6 +289,9 @@ def validate_gvalue(self, attribute, value):
@demography.validator
def validate_demography(self, attribute, value):
if value is None:
warnings.warn("No demographic model specified."
" This will be a hard error in a future release.",
DeprecationWarning)
return

if isinstance(value, fwdpy11.ForwardDemesGraph):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_add_mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def generate_msprime_ancestry(
"recregions": [fwdpy11.PoissonInterval(0, 1, 5e-2)],
"gvalue": fwdpy11.Multiplicative(2.0),
"rates": (0, 0, None),
"demography": fwdpy11.ForwardDemesGraph.tubes([pop.N],
burnin=10*pop.N,
burnin_is_exact=True),
"prune_selected": False,
"simlen": 10 * pop.N,
}
Expand Down

0 comments on commit 715db96

Please sign in to comment.