def sexer_randompairs(n): '''Yields n of each of two sexes, in pairs, in random order. Assumes from __future__ import division. ''' sexgen = utilities.n_each_rand(n,itemtuple="MF") while True: yield sexgen.next() + sexgen.next()
def sexer_randompairs(n): '''Yields n of each of two sexes, in pairs, in random order. Assumes from __future__ import division. ''' sexgen = utilities.n_each_rand(n, itemtuple="MF") while True: yield sexgen.next() + sexgen.next()
def test_n_each_rand(self): n = random.randrange(500) TF = n_each_rand(n, (True, False)) TFlist = list(TF) nT = TFlist.count(True) nF = TFlist.count(False) self.assertEqual(n, nT) self.assertEqual(n, nF)