Skip to content

Commit

Permalink
tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Aug 18, 2023
1 parent 4b846c7 commit f6c2a0e
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 36 deletions.
2 changes: 1 addition & 1 deletion tests/test_add_mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def set_up_quant_trait_model():
# mu = theta/(4*N)
r = rho / (4 * N)
Opt = fwdpy11.Optimum
GSSmo = fwdpy11.GSSmo(
GSSmo = fwdpy11.GaussianStabilizingSelection.single_trait(
[Opt(when=0, optimum=0.0, VS=1.0), Opt(when=N, optimum=1.0, VS=1.0)]
)
a = fwdpy11.Additive(2.0, GSSmo)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_dgvalue_pointer_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def test_construct_from_empty_list(self):

def test_invalid_dimensionality(self):
a = fwdpy11.Additive(2.0)
mvgss = fwdpy11.MultivariateGSS(np.zeros(2), 10.0)
mvgss = fwdpy11.GaussianStabilizingSelection.pleiotropy(
[fwdpy11.PleiotropicOptima(np.zeros(2), 10.0, when=0)])
mv = fwdpy11.StrictAdditiveMultivariateEffects(2, 0, mvgss)
from fwdpy11._fwdpy11 import _dgvalue_pointer_vector

Expand Down
28 changes: 11 additions & 17 deletions tests/test_genetic_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ class testAdditive(unittest.TestCase):
def setUp(self):
GN = fwdpy11.GaussianNoise
self.w = fwdpy11.Additive(2.0)
self.t = fwdpy11.Additive(2.0, fwdpy11.GSS(0.0, 1.0))
self.t = fwdpy11.Additive(2.0, fwdpy11.GaussianStabilizingSelection.single_trait(
[fwdpy11.Optimum(0.0, 1.0, 0)]))
self.tn = fwdpy11.Additive(
1.0, fwdpy11.GSS(0.0, 1.0), GN(mean=0.1, sd=2.0))
1.0, fwdpy11.GaussianStabilizingSelection.single_trait([fwdpy11.Optimum(0.0, 1.0, 0)]), GN(mean=0.1, sd=2.0))

def testScaling(self):
self.assertEqual(self.w.scaling, 2.0)
Expand Down Expand Up @@ -74,13 +75,15 @@ def testPickleTraitWithNoiseToFile(self):


class testMultiplicative(unittest.TestCase):
@classmethod
@ classmethod
def setUp(self):
GN = fwdpy11.GaussianNoise
self.w = fwdpy11.Multiplicative(2.0)
self.t = fwdpy11.Multiplicative(2.0, fwdpy11.GSS(0.0, 1.0))
self.t = fwdpy11.Multiplicative(
2.0, fwdpy11.GaussianStabilizingSelection.single_trait([fwdpy11.Optimum(0.0, 1.0)]))
self.tn = fwdpy11.Multiplicative(
1.0, fwdpy11.GSS(0.0, 1.0), GN(mean=0.1, sd=2.0)
1.0, fwdpy11.GaussianStabilizingSelection.single_trait(
[fwdpy11.Optimum(0.0, 1.0, 0)]), GN(mean=0.1, sd=2.0)
)

def testScaling(self):
Expand Down Expand Up @@ -131,9 +134,10 @@ def testPickleTraitWithNoise(self):


class testGBR(unittest.TestCase):
@classmethod
@ classmethod
def setUp(self):
self.gss = fwdpy11.GSS(0.0, 1.0)
self.gss = fwdpy11.GaussianStabilizingSelection.single_trait(
[fwdpy11.Optimum(0.0, 1.0, 0)])
self.gnoise = fwdpy11.GaussianNoise(mean=0.0, sd=1.0)
self.nonoise = fwdpy11.NoNoise()

Expand All @@ -160,15 +164,5 @@ def testPicklingGSSGaussianNoise(self):
self.assertEqual(type(self.gss), type(up.gvalue_to_fitness))


class testGSS(unittest.TestCase):
@classmethod
def setUp(self):
self.x = fwdpy11.GSS(0.0, 1.0)

def testProperties(self):
self.assertEqual(self.x.optimum, 0.0)
self.assertEqual(self.x.VS, 1.0)


if __name__ == "__main__":
unittest.main()
3 changes: 2 additions & 1 deletion tests/test_inherited_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def setUp(self):
[100] * 3, 1),
"simlen": 3,
"gvalue": fwdpy11.Additive(
2.0, fwdpy11.GSS(optimum=0.0, VS=1.0), InheritedNoise()
2.0, fwdpy11.GaussianStabilizingSelection.single_trait(
[fwdpy11.Optimum(optimum=0.0, VS=1.0, when=0)]), InheritedNoise()
),
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_multivariate_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def set_up_quant_trait_model():
po = []
for i, j in enumerate(timepoints):
po.append(PO(when=int(j), optima=optima[i, :], VS=1.0))
GSSmo = fwdpy11.MultivariateGSSmo(po)
GSSmo = fwdpy11.GaussianStabilizingSelection.pleiotropy(po)
cmat = np.identity(ntraits)
np.fill_diagonal(cmat, 0.1)
a = fwdpy11.StrictAdditiveMultivariateEffects(ntraits, 0, GSSmo)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_pickling.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def setUp(self):
self.mu = self.theta / (4 * self.N)
self.r = self.rho / (4 * self.N)

self.GSS = fwdpy11.GSS(VS=1.0, optimum=0.0)
self.GSS = fwdpy11.GaussianStabilizingSelection.single_trait(
[fwdpy11.Optimum(VS=1.0, optimum=0.0, when=0)])
a = fwdpy11.Additive(2.0, self.GSS)
demography = fwdpy11.ForwardDemesGraph.tubes([self.N],
burnin=100,
Expand Down
9 changes: 5 additions & 4 deletions tests/test_python_genetic_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def test_run(self):
# ndemes=2, scaling=2, gvalue_to_fitness=
ndemes=2,
scaling=2,
gvalue_to_fitness=fwdpy11.GSS(
fwdpy11.Optimum(optimum=0.0, VS=1.0)),
gvalue_to_fitness=fwdpy11.GaussianStabilizingSelection.single_trait([
fwdpy11.Optimum(optimum=0.0, VS=1.0)]),
)
params = fwdpy11.ModelParams(**pdict)
pop2 = fwdpy11.DiploidPopulation([1000, 1000], 1.0)
Expand Down Expand Up @@ -124,7 +124,8 @@ def test_run(self):

import pynoise

GSS = fwdpy11.GSS(optimum=0.0, VS=1.0)
GSS = fwdpy11.fwdpy11.GaussianStabilizingSelection.single_trait(
[fwdpy11.Optimum(optimum=0.0, VS=1.0, when=0)])
Noise = pynoise.PyNoise()
pdict = build_model(GSS, Noise, 5, [1000, 1000])
params = fwdpy11.ModelParams(**pdict)
Expand Down Expand Up @@ -202,7 +203,7 @@ def test_run(self):
md = np.array(pop.diploid_metadata)

pdict["gvalue"] = fwdpy11.Additive(
2.0, fwdpy11.GSS(optimum=0.0, VS=1.0))
2.0, fwdpy11.GaussianStabilizingSelection.single_trait([fwdpy11.Optimum(optimum=0.0, VS=1.0, when=0)]))
params = fwdpy11.ModelParams(**pdict)
pop2 = fwdpy11.DiploidPopulation(1000, 1.0)
rng = fwdpy11.GSLrng(1010)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_record_genetic_value_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def set_up_quant_trait_model():
rho = 1.0
r = rho / (4 * N)
Opt = fwdpy11.Optimum
GSSmo = fwdpy11.GSSmo(
GSSmo = fwdpy11.GaussianStabilizingSelection.single_trait(
[Opt(when=0, optimum=0.0, VS=1.0), Opt(
when=N, optimum=1.0, VS=1.0)]
)
Expand Down Expand Up @@ -72,7 +72,7 @@ def set_up_two_trait_quant_trait_model():
when=N, optima=np.array([np.sqrt(2.0), 0]), VS=2.0
),
]
GSSmo = fwdpy11.MultivariateGSSmo(optima)
GSSmo = fwdpy11.GaussianStabilizingSelection.pleiotropy(optima)
a = fwdpy11.StrictAdditiveMultivariateEffects(2, 0, GSSmo)
vcov = np.identity(2)
np.fill_diagonal(vcov, 0.25)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_recreate_pop_from_own_treeseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def pop_rng_params():
"recregions": [fwdpy11.BinomialInterval(0, L, 1)],
"rates": (0.0, mu, None),
"gvalue": fwdpy11.Additive(
scaling=2, gvalue_to_fitness=fwdpy11.GSS(optimum=optimum, VS=VS)
scaling=2, gvalue_to_fitness=fwdpy11.GaussianStabilizingSelection.single_trait([fwdpy11.Optimum(optimum=optimum, VS=VS, when=0)])
),
"simlen": simlen,
"prune_selected": False,
Expand Down
17 changes: 11 additions & 6 deletions tests/test_tree_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def set_up_quant_trait_model(simlen=1.0):
# mu = theta/(4*N)
r = rho / (4 * N)
Opt = fwdpy11.Optimum
GSSmo = fwdpy11.GSSmo(
GSSmo = fwdpy11.GaussianStabilizingSelection.single_trait(
[Opt(when=0, optimum=0.0, VS=1.0), Opt(when=N, optimum=1.0, VS=1.0)]
)
a = fwdpy11.Additive(2.0, GSSmo)
Expand Down Expand Up @@ -998,7 +998,8 @@ def setUpClass(self):
self.nreps = 500
self.mu = self.theta / (4 * self.N)
self.r = self.rho / (4 * self.N)
self.GSS = fwdpy11.GSS(VS=1.0, optimum=0.0)
self.GSS = fwdpy11.fwdpy11.GaussianStabilizingSelection.single_trait(
[fwdpy11.Optimum(VS=1.0, optimum=0.0, when=0)])
a = fwdpy11.Additive(2.0, self.GSS)
self.p = {
"nregions": [],
Expand Down Expand Up @@ -1031,7 +1032,8 @@ def testQtraitSim(self):
rho = 1.0
r = rho / (4 * N)

GSS = fwdpy11.GSS(VS=1.0, optimum=1.0)
GSS = fwdpy11.GaussianStabilizingSelection.single_trait(
[fwdpy11.Optimum(VS=1.0, optimum=1.0, when=0)])
a = fwdpy11.Additive(2.0, GSS)
p = {
"nregions": [],
Expand Down Expand Up @@ -1115,7 +1117,8 @@ def testQtraitSim(self):
rho = 1.0
r = rho / (4 * N)

GSS = fwdpy11.GSS(VS=1.0, optimum=1.0)
GSS = fwdpy11.GaussianStabilizingSelection.single_trait(
[fwdpy11.Optimum(VS=1.0, optimum=1.0, when=0)])
a = fwdpy11.Additive(2.0, GSS)
p = {
"nregions": [],
Expand Down Expand Up @@ -1208,7 +1211,8 @@ def setUpClass(self):
self.mu = self.theta / (4 * self.N)
self.r = self.rho / (4 * self.N)

self.GSS = fwdpy11.GSS(VS=1.0, optimum=0.0)
self.GSS = fwdpy11.GaussianStabilizingSelection.single_trait(
[fwdpy11.Optimum(VS=1.0, optimum=0.0, when=0)])
a = fwdpy11.Additive(2.0, self.GSS)
self.p = {
"nregions": [],
Expand Down Expand Up @@ -1353,7 +1357,8 @@ def __call__(self, pop):
self.rho = 1.0
self.r = self.rho / (4 * self.N)

self.GSS = fwdpy11.GSS(VS=1.0, optimum=0.0)
self.GSS = fwdpy11.GaussianStabilizingSelection.single_trait(
[fwdpy11.Optimum(VS=1.0, optimum=0.0, when=0)])
a = fwdpy11.Additive(2.0, self.GSS)
self.p = {
"nregions": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def setUpClass(self):
"demography": demography,
"simlen": 100,
"gvalue": fwdpy11.Additive(
ndemes=2, scaling=2, gvalue_to_fitness=fwdpy11.GSS(optimum=0.0, VS=1.0)
ndemes=2, scaling=2, gvalue_to_fitness=fwdpy11.GaussianStabilizingSelection.single_trait([fwdpy11.Optimum(optimum=0.0, VS=1.0, when=0)])
),
}

Expand Down

0 comments on commit f6c2a0e

Please sign in to comment.