Skip to content

Commit

Permalink
swapped function name
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkern authored and petrelharp committed Oct 29, 2021
1 parent 7e7f27f commit 4467f53
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions stdpopsim/genomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def all_intervals_array(self):
all_intervals = stdpopsim.utils.build_intervals_array(all_intervals)
return all_intervals

def clear_features(self):
def clear_DFEs(self):
"""
convenience function to clear dfe_list and interval_list
"""
Expand All @@ -343,7 +343,7 @@ def add_DFE(self, intervals, DFE, fill_neutral=True):
if len(self.dfe_list) >= 2:
raise ValueError("only single DFE + neutral sites implemented")
if fill_neutral:
self.clear_features()
self.clear_DFEs()
stdpopsim.utils.check_intervals_validity(intervals)
self.dfe_list.append(DFE)
self.interval_list.append(intervals)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_non_neutral_contig(self):
model = species.get_demographic_model("AshkSub_7G19")
samples = model.get_samples(10)
contig = stdpopsim.Contig.basic_contig(length=100)
contig.clear_features()
contig.clear_DFEs()
props = [1]
mt = [stdpopsim.ext.MutationType(distribution_type="f", distribution_args=[1])]
dfes = [
Expand All @@ -128,7 +128,7 @@ def test_non_neutral_contig(self):
with pytest.raises(ValueError):
engine.simulate(model, contig, samples, seed=1)
# okay now change selection coefficient to neutral
contig.clear_features()
contig.clear_DFEs()
props = [1]
mt = [stdpopsim.ext.MutationType(distribution_type="f", distribution_args=[0])]
dfes = [
Expand Down
12 changes: 6 additions & 6 deletions tests/test_genomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_add_DFE_errors(self):

def test_add_DFE(self):
contig = stdpopsim.Contig.basic_contig(length=100)
contig.clear_features()
contig.clear_DFEs()
props = [0.3, 0.7]
mt = [stdpopsim.ext.MutationType() for _ in props]
dfes = [
Expand All @@ -57,7 +57,7 @@ def test_add_DFE(self):

def test_is_neutral(self):
contig = stdpopsim.Contig.basic_contig(length=100)
contig.clear_features()
contig.clear_DFEs()
props = [0.3, 0.7]
mt = [
stdpopsim.ext.MutationType(distribution_type="f", distribution_args=[1])
Expand All @@ -81,7 +81,7 @@ def test_is_neutral(self):

def test_is_neutral2(self):
contig = stdpopsim.Contig.basic_contig(length=100)
contig.clear_features()
contig.clear_DFEs()
props = [0.3, 0.7]
mt = [stdpopsim.ext.MutationType() for _ in props]
dfes = [
Expand All @@ -102,7 +102,7 @@ def test_is_neutral2(self):

def test_is_neutral3(self):
contig = stdpopsim.Contig.basic_contig(length=100)
contig.clear_features()
contig.clear_DFEs()
props = [0.3, 0.7]
mt = [
stdpopsim.ext.MutationType(distribution_type="e", distribution_args=[1])
Expand All @@ -126,7 +126,7 @@ def test_is_neutral3(self):

def test_too_many_dfes(self):
contig = stdpopsim.Contig.basic_contig(length=100)
contig.clear_features()
contig.clear_DFEs()
props = [0.3, 0.7]
mt = [
stdpopsim.ext.MutationType(distribution_type="e", distribution_args=[1])
Expand Down Expand Up @@ -307,7 +307,7 @@ def test_simulation_runs(self):
length=10000,
mutation_rate=1e-6, # Ne=1e3 and length=1e4 so theta=40
)
contig.clear_features()
contig.clear_DFEs()
contig.add_DFE(
intervals=np.array([[0, contig.length / 2]], dtype="int"),
DFE=self.dfe,
Expand Down
16 changes: 8 additions & 8 deletions tests/test_slim_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ def test_single_genomic_element_type_in_script(self):
def test_multiple_genomic_element_types_in_script(self):
contig = get_test_contig()
engine = stdpopsim.get_engine("slim")
contig.clear_features()
contig.clear_DFEs()
contig.add_DFE(
np.array([[0, 100]]), stdpopsim.dfe.neutral_DFE(), fill_neutral=False
)
Expand Down Expand Up @@ -781,7 +781,7 @@ def test_unweighted_mutations_are_not_simulated_by_slim(self):
proportions=[0, 0],
mutation_types=mt,
)
contig.clear_features()
contig.clear_DFEs()
contig.add_DFE(
np.array([[0, contig.length]], dtype="int32"), test_d, fill_neutral=False
)
Expand All @@ -807,7 +807,7 @@ def test_unweighted_mutations_are_not_simulated_by_slim(self):
proportions=[0, 0],
mutation_types=mt,
)
contig.clear_features()
contig.clear_DFEs()
contig.add_DFE(
np.array([[10, contig.length]], dtype="int32"), test_d, fill_neutral=True
)
Expand Down Expand Up @@ -1624,14 +1624,14 @@ def test_add_dfe_misc(self):
proportions=[0, 1],
mutation_types=mt,
)
contig.clear_features()
contig.clear_DFEs()
contig.add_DFE(
np.array([[contig.length - 1, contig.length]], dtype="int32"),
test_d,
fill_neutral=True,
)
assert contig.interval_list[1].shape == (1, 2)
contig.clear_features()
contig.clear_DFEs()
contig.add_DFE(
np.array([[contig.length - 2, contig.length - 1]], dtype="int32"),
test_d,
Expand Down Expand Up @@ -1661,7 +1661,7 @@ def test_slim_fractions(self):
proportions = ([0, 1.0], [0.5, 0.5], [0, 0], [0.2, 0])
for props in proportions:
slim_frac = np.array(sum(props))
contig.clear_features()
contig.clear_DFEs()
test_d.proportions = props
contig.add_DFE(test_int, test_d, fill_neutral=False)
assert (slim_frac == stdpopsim.slim_engine.get_slim_fractions(contig)).all()
Expand Down Expand Up @@ -1708,7 +1708,7 @@ def test_complex_mutation_rate_maps(self):
mutation_types=mt,
)
for prop1, prop2 in ((0.3, 0.7), (0.7, 0.3), (1.0, 0.0)):
contig.clear_features()
contig.clear_DFEs()
test_d.proportions = [prop1]
contig.add_DFE(np.array([[10, 100]]), test_d, fill_neutral=True)
contig.dfe_list[1].proportions = [0]
Expand All @@ -1734,7 +1734,7 @@ def test_complex_mutation_rate_maps(self):
np.isclose(np.array(obs_slim_rates), np.array(exp_slim_rates))
).all()

contig.clear_features()
contig.clear_DFEs()
contig.add_DFE(np.array([[0, 50]]), test_d, fill_neutral=False)
test_d2 = stdpopsim.DFE(
id="test",
Expand Down

0 comments on commit 4467f53

Please sign in to comment.