Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate use of None for a demographic model. #1219

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/misc/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ python -Wd

```

To treat all warning as errors:

```{code-block} bash

python -We

```
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