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

remove ll_representation argument #2231

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 10 additions & 30 deletions msprime/demography.py
Original file line number Diff line number Diff line change
Expand Up @@ -3002,9 +3002,7 @@ def __post_init__(self):
raise ValueError("Cannot have a population size < 0")
self.population = -1 if self.population is None else self.population

def get_ll_representation(self, num_populations=None):
# We need to keep the num_populations argument until stdpopsim 0.2 is out
# https://github.com/tskit-dev/msprime/issues/1037
def get_ll_representation(self):
ret = {
"type": "population_parameters_change",
"time": self.time,
Expand Down Expand Up @@ -3082,9 +3080,7 @@ def __post_init__(self):
self.source = self.matrix_index[0]
self.dest = self.matrix_index[1]

def get_ll_representation(self, num_populations=None):
# We need to keep the num_populations argument until stdpopsim 0.1 is out
# https://github.com/tskit-dev/msprime/issues/1037
def get_ll_representation(self):
return {
"type": "migration_rate_change",
"time": self.time,
Expand Down Expand Up @@ -3123,9 +3119,7 @@ class SymmetricMigrationRateChange(ParameterChangeEvent):
default="Symmetric migration rate change", repr=False
)

def get_ll_representation(self, num_populations=None):
# We need to keep the num_populations argument until stdpopsim 0.1 is out
# https://github.com/tskit-dev/msprime/issues/1037
def get_ll_representation(self):
return {
"type": "symmetric_migration_rate_change",
"time": self.time,
Expand Down Expand Up @@ -3217,9 +3211,7 @@ def __post_init__(self):
if self.destination is not None:
self.dest = self.destination

def get_ll_representation(self, num_populations=None):
# We need to keep the num_populations argument until stdpopsim 0.1 is out
# https://github.com/tskit-dev/msprime/issues/1037
def get_ll_representation(self):
return {
"type": "mass_migration",
"time": self.time,
Expand Down Expand Up @@ -3276,9 +3268,7 @@ class ActivatePopulationEvent(DemographicEvent):
default="Activate population event", repr=False
)

def get_ll_representation(self, num_populations=None):
# We need to keep the num_populations argument until stdpopsim 0.1 is out
# https://github.com/tskit-dev/msprime/issues/1037
def get_ll_representation(self):
return {
"type": "activate_population_event",
"time": self.time,
Expand Down Expand Up @@ -3307,9 +3297,7 @@ class PopulationSplit(LineageMovementEvent):

_type_str: ClassVar[str] = dataclasses.field(default="Population Split", repr=False)

def get_ll_representation(self, num_populations=None):
# We need to keep the num_populations argument until stdpopsim 0.1 is out
# https://github.com/tskit-dev/msprime/issues/1037
def get_ll_representation(self):
return {
"type": "population_split",
"time": self.time,
Expand Down Expand Up @@ -3369,9 +3357,7 @@ class Admixture(LineageMovementEvent):
def num_ancestral(self):
return len(self.ancestral)

def get_ll_representation(self, num_populations=None):
# We need to keep the num_populations argument until stdpopsim 0.1 is out
# https://github.com/tskit-dev/msprime/issues/1037
def get_ll_representation(self):
return {
"type": "admixture",
"time": self.time,
Expand Down Expand Up @@ -3424,9 +3410,7 @@ class SimpleBottleneck(StateChangeEvent):
population: int
proportion: float = 1.0

def get_ll_representation(self, num_populations=None):
# We need to keep the num_populations argument until stdpopsim 0.1 is out
# https://github.com/tskit-dev/msprime/issues/1037
def get_ll_representation(self):
return {
"type": "simple_bottleneck",
"time": self.time,
Expand Down Expand Up @@ -3454,9 +3438,7 @@ class InstantaneousBottleneck(StateChangeEvent):
population: int
strength: float = 1.0

def get_ll_representation(self, num_populations=None):
# We need to keep the num_populations argument until stdpopsim 0.1 is out
# https://github.com/tskit-dev/msprime/issues/1037
def get_ll_representation(self):
return {
"type": "instantaneous_bottleneck",
"time": self.time,
Expand Down Expand Up @@ -3497,9 +3479,7 @@ class CensusEvent(DemographicEvent):

_type_str: ClassVar[str] = dataclasses.field(default="Census", repr=False)

def get_ll_representation(self, num_populations=None):
# We need to keep the num_populations argument until stdpopsim 0.1 is out
# https://github.com/tskit-dev/msprime/issues/1037
def get_ll_representation(self):
return {
"type": "census_event",
"time": self.time,
Expand Down
24 changes: 0 additions & 24 deletions tests/test_demography.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,30 +315,6 @@ def test_census(self):
assert str(event) == repr_s


class TestDemographicEventsHaveExtraLLParameter:
"""
For legacy reasons the DemographicEvent.get_ll_representation took
a "num_populations" argument. In versions of stdpopsim using
msprime < 1.0, this parameter was specified when testing for
model equality (even though it did nothing). To ensure we're not
breaking older versions of stdpopsim, we keep this extra parameter
and test it here to make sure it works.

Since the functionality is only really used as a developer tool
in stdpopsim, we can get rid of the extra parameters once
stdpopsim 0.2 (which won't use this API) has been released.

See https://github.com/tskit-dev/msprime/issues/1037
"""

def test_demographic_events_have_param(self):
demography = all_events_example_demography()
for event in demography.events:
ll_config1 = event.get_ll_representation()
ll_config2 = event.get_ll_representation(None)
assert ll_config1 == ll_config2


class TestTimeTravelErrors:
"""
It is possible to specify models in msprime that result in malformed
Expand Down
Loading