def testAssocDirection(self): """Test that AA gives same answer for either order of series""" lags = [(i - 144) * 120 for i in range(289)] pop = poppy.PPro(self.t1, self.t2, lags=lags, winhalf=120) pop.assoc() poprev = poppy.PPro(self.t2, self.t1, lags=lags[-1::-1], winhalf=120) poprev.assoc() self.assertTrue((pop.assoc_total == poprev.assoc_total).all())
def testAssocRegress(self): """Test entire association analysis This is a regression test: values are taken from existing implementation and assumed correct. """ pop = poppy.PPro(self.t1, self.t2) lags = [(i - 144) * 120 for i in range(289)] pop.assoc(lags, 120) expected = [3.0, 2.0, 1.0, 1.0, 3.0, 2.0, 2.0, 4.0, 3.0, 3.0, 3.0, 1.0, 0.0, 2.0, 2.0, 2.0, 5.0, 5.0, 5.0, 3.0, 0.0, 2.0, 5.0, 5.0, 4.0, 4.0, 5.0, 7.0, 4.0, 1.0, 2.0, 2.0, 3.0, 4.0, 6.0, 4.0, 3.0, 3.0, 2.0, 3.0, 4.0, 6.0, 5.0, 2.0, 1.0, 3.0, 4.0, 3.0, 3.0, 4.0, 3.0, 1.0, 1.0, 1.0, 2.0, 3.0, 2.0, 4.0, 6.0, 7.0, 5.0, 2.0, 4.0, 5.0, 4.0, 7.0, 6.0, 2.0, 3.0, 5.0, 4.0, 3.0, 4.0, 5.0, 4.0, 1.0, 2.0, 4.0, 3.0, 2.0, 3.0, 3.0, 1.0, 3.0, 5.0, 2.0, 3.0, 4.0, 1.0, 1.0, 3.0, 4.0, 3.0, 2.0, 6.0, 6.0, 2.0, 3.0, 3.0, 2.0, 2.0, 2.0, 3.0, 2.0, 3.0, 3.0, 3.0, 4.0, 2.0, 4.0, 3.0, 1.0, 1.0, 0.0, 0.0, 2.0, 3.0, 1.0, 1.0, 1.0, 1.0, 3.0, 3.0, 2.0, 1.0, 1.0, 1.0, 0.0, 2.0, 5.0, 6.0, 4.0, 3.0, 4.0, 3.0, 2.0, 3.0, 4.0, 4.0, 6.0, 5.0, 2.0, 3.0, 3.0, 1.0, 2.0, 4.0, 3.0, 3.0, 3.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 3.0, 4.0, 4.0, 4.0, 2.0, 4.0, 4.0, 2.0, 1.0, 3.0, 3.0, 1.0, 2.0, 6.0, 5.0, 1.0, 2.0, 4.0, 4.0, 2.0, 1.0, 2.0, 2.0, 4.0, 4.0, 2.0, 3.0, 5.0, 4.0, 5.0, 7.0, 4.0, 1.0, 1.0, 2.0, 3.0, 4.0, 4.0, 4.0, 6.0, 5.0, 3.0, 4.0, 4.0, 3.0, 2.0, 4.0, 3.0, 3.0, 3.0, 2.0, 4.0, 4.0, 4.0, 3.0, 2.0, 3.0, 4.0, 5.0, 6.0, 4.0, 2.0, 4.0, 6.0, 4.0, 2.0, 0.0, 0.0, 2.0, 3.0, 6.0, 6.0, 3.0, 2.0, 1.0, 2.0, 2.0, 1.0, 3.0, 6.0, 5.0, 4.0, 6.0, 5.0, 2.0, 2.0, 3.0, 4.0, 4.0, 4.0, 2.0, 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 3.0, 1.0, 0.0, 2.0, 3.0, 4.0, 6.0, 5.0, 3.0, 4.0, 3.0, 3.0, 3.0, 3.0, 2.0, 3.0, 7.0, 5.0, 1.0, 0.0, 3.0, 4.0, 6.0, 4.0, 0.0, 2.0, 2.0, 1.0, 2.0, 2.0, 1.0, 0.0, 2.0, 3.0] self.assertEqual(expected, list(pop.assoc_total))
def test_str(self): """__str__ should give known results""" pop = poppy.PPro(self.t1, self.t2) self.assertEqual( str(pop), 'Point Process Object:\n Points in process #1 - 100 ; Points in process #2 - 100\n Peak association number - N/A ; Asymptotic association - N/A\n ' )
def testAssocBootstrapRegress(self): """Test entire association analysis with bootstrap This is a regression test: values are taken from existing implementation and assumed correct. """ if sys.maxsize <= 2**31: #don't test on 32-bit return pop = poppy.PPro(self.t1, self.t2) lags = [(i - 144) * 120 for i in range(289)] pop.assoc(lags, 120) pop.aa_ci(95, n_boots=100, seed=0) self.assertEqual(self.expected_low, list(pop.ci[0])) self.assertEqual(self.expected_high, list(pop.ci[1])) self.assertEqual(self.expected_conf_above, list(pop.conf_above))
def test_swap(self): """swap() should swap the processes""" pop = poppy.PPro(self.t1, self.t2) pop.swap() self.assertEqual(pop.process1, self.t2) self.assertEqual(pop.process2, self.t1)
def test_len(self): """__len__ has a known behaviour""" pop = poppy.PPro(self.t1, self.t2) self.assertEqual(len(pop), 100)