Skip to content

Commit

Permalink
Add test for #35
Browse files Browse the repository at this point in the history
  • Loading branch information
BoPeng committed Feb 28, 2019
1 parent 32d923d commit cb4926d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/test_05_matings.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,24 @@ def testWeightingSchemeBySex(self):
self.assertEqual(marks.count(1.), 0)
self.assertEqual(marks.count(2.), 0)

def testWeightByWithEmptySubpop(self):
'''Test weightBy option when there are empty subpopulations'''
pop = Population(size=[1000, 0], loci=2, infoFields='mark')
pop.setVirtualSplitter(RangeSplitter([[0, 500], [200, 1000]]))
# weighting scheme of -0.5, 2, 3
pop.evolve(
initOps=InitSex(sex=[MALE, FEMALE]),
matingScheme=HeteroMating([
RandomMating(weight=-0.5,
ops=[InfoExec('mark=0'), MendelianGenoTransmitter()]),
RandomMating(subPops=[(ALL_AVAIL, 0)], weight=1,
ops=[InfoExec('mark=1'), MendelianGenoTransmitter()]),
RandomMating(subPops=[(ALL_AVAIL, 1)], weight=2,
ops=[InfoExec('mark=2'), MendelianGenoTransmitter()])
], weightBy=MALE_ONLY),
gen = 1
)

def testPolygamousMating(self):
'Testing polygamous mating scheme'
pop = Population(size=[200], loci=[3,5], infoFields=['father_idx', 'mother_idx'])
Expand Down

0 comments on commit cb4926d

Please sign in to comment.