예제 #1
0
 def test_typecheck(self):
     with self.assertRaises(TypeError):
         PyPgen.NHPP(
             ((), ),
             ((), ),
             ((), ),
         )
예제 #2
0
    def test_halfsinus3D(self):
        phase_1 = 0
        phase_2 = 0
        phase_3 = 0
        period_1 = 1
        period_2 = 2
        period_3 = 3
        amplitude = 1
        offset = 1
        rate_max = amplitude + amplitude + amplitude + offset
        dimensions = 3

        def rate_halfsinus3D(x_1, x_2, x_3):
            sins = np.sin(2.*np.pi*x_1/period_1 + phase_1) + \
                np.sin(2.*np.pi*x_2/period_2 + phase_2) + \
                np.sin(2.*np.pi*x_3/period_3 + phase_3)
            out = amplitude * (sins * (sins > 0)) + offset
            return (out)

        bounds = [[1, 10], [10, 20], [20, 21]]
        out = PyPgen.NHPP(rate_halfsinus3D, rate_max, bounds)
        self.assertTrue(out.shape[-1] == dimensions)
        self.assertTrue(len(out.shape) > 1)
        self.assertTrue(np.amin(out[:, 0]) > bounds[0][0])
        self.assertTrue(np.amax(out[:, 0]) < bounds[0][1])
        self.assertTrue(np.amin(out[:, 1]) > bounds[1][0])
        self.assertTrue(np.amax(out[:, 1]) < bounds[1][1])
        self.assertTrue(np.amin(out[:, 2]) > bounds[2][0])
        self.assertTrue(np.amax(out[:, 2]) < bounds[2][1])
예제 #3
0
    def test_halfsinus1D(self):
        phase = 0
        period = 2
        amplitude = 3
        offset = 1
        rate_max = amplitude + offset
        dimensions = 1

        def rate_halfsinus1D(time):
            sins = np.sin(2. * np.pi * time / period + phase)
            out = amplitude * (sins * (sins > 0)) + offset
            return (out)

        bounds = [1, 10]
        out = PyPgen.NHPP(rate_halfsinus1D, rate_max, bounds)
        self.assertTrue(out.shape[-1] == dimensions)
        self.assertTrue(len(out.shape) > 1)
        self.assertTrue(np.amin(out) > bounds[0])
        self.assertTrue(np.amax(out) < bounds[1])