Ejemplo n.º 1
0
 def test_change_zoom_level_smaller_content(self):
     cy.clear_array(self.dim, self.arr)
     randomize_center(10, self.dim, self.arr)
     dim, buf, change, self.buf_stat = change_zoom_level(
         self.position, self.buf_len, self.buf_stat, self.change_roll,
         self.dim, self.buf)
     nu_arr = buf[self.position[0]]
     self.assertEqual(np.sum(self.arr), np.sum(nu_arr))
Ejemplo n.º 2
0
 def test_change_zoom_level_smaller(self):
     cy.clear_array(self.dim, self.arr)
     self.assertEqual(len(self.buf_stat), 1)
     dim, buf, change, self.buf_stat = change_zoom_level(
         self.position, self.buf_len, self.buf_stat, self.change_roll,
         self.dim, self.buf)
     self.assertEqual(change[0, 1], -1)
     self.assertEqual(dim[0], self.dim[0] - 2)
     self.assertEqual(len(self.buf_stat), 2)
Ejemplo n.º 3
0
    def test_advance_array_wraps(self):
        self.buf[0] = 0
        cy.clear_array(tst_dimL(), self.buf[self.buf_len - 1])
        add_global_noise(0.5, tst_dimL(), self.buf[self.buf_len - 1])
        testing.assert_almost_equal(np.mean(self.buf[self.buf_len - 1]),
                                    np.mean(np.random.randint(0, 2, self.dim)),
                                    decimal=2)

        self.position[0] = self.buf_len - 1
        advance_array(self.position, self.buf_len, self.buf)
        testing.assert_array_equal(self.buf[0], self.buf[self.buf_len - 1])
Ejemplo n.º 4
0
 def test_analysis_loop_empty(self):
     cy.clear_array(tst_dimL(), self.arr)
     com = center_of_mass(tst_dimL(), self.arr)
     tot, living, com, Rg, M = analysis_loop(com, tst_dimL(), self.arr)
     self.assertEqual(len(np.argwhere(self.arr)), tot)
     self.assertEqual(len(np.argwhere(self.arr)), len(living))
     com_P = center_of_mass_P(np.argwhere(self.arr),
                              len(np.argwhere(self.arr)))
     testing.assert_allclose(com, com_P)
     com_P = center_of_mass_P(np.argwhere(self.arr),
                              len(np.argwhere(self.arr)))
     Rg_P = radius_of_gyration_P(com_P, np.argwhere(self.arr),
                                 len(np.argwhere(self.arr)))
     testing.assert_allclose(Rg, Rg_P, 1e-8, 1e-2)
     self.assertAlmostEqual(polarization(tst_dimL(), self.arr), M)
Ejemplo n.º 5
0
 def test_analysis_loop_energy_empty(self):
     cy.clear_array(tst_dimL(), self.arr)
     com = center_of_mass(tst_dimL(), self.arr)
     tot, living, com, Rg, e, e2, M = analysis_loop_energy(
         com, tst_dimL(), self.arr)
     self.assertEqual(len(np.argwhere(self.arr)), tot)
     self.assertEqual(len(np.argwhere(self.arr)), len(living))
     com_P = center_of_mass_P(np.argwhere(self.arr),
                              len(np.argwhere(self.arr)))
     testing.assert_allclose(com, com_P)
     Rg_P = radius_of_gyration_P(com_P, np.argwhere(self.arr),
                                 len(np.argwhere(self.arr)))
     testing.assert_allclose(Rg, Rg_P, 1e-8, 1e-2)
     E, E2 = neighbor_interaction(tst_dimL(), self.arr)
     EE, EE2 = neighbor_interaction_moore(tst_dimL(), self.arr)
     self.assertAlmostEqual(e, -8, 1)
     self.assertLess(e, e2)
     self.assertAlmostEqual(E, e, 5)
     self.assertAlmostEqual(EE, e, 5)
     self.assertAlmostEqual(E2, e2, 5)
     self.assertAlmostEqual(EE2, e2, 5)
     self.assertAlmostEqual(1, M, 2)
     self.assertAlmostEqual(polarization(tst_dimL(), self.arr), M)
Ejemplo n.º 6
0
 def test_change_zoom_level_array_smaller_content(self):
     cy.clear_array(self.dim, self.arr)
     randomize_center(10, self.dim, self.arr)
     dim, arr, change = change_zoom_level_array(self.dim, self.arr)
     testing.assert_array_equal(self.arr[1:-1, 1:-1], arr)
Ejemplo n.º 7
0
 def test_change_zoom_level_array_smaller(self):
     cy.clear_array(self.dim, self.arr)
     dim, arr, change = change_zoom_level_array(self.dim, self.arr)
     self.assertEqual(change, -1)
     self.assertEqual(dim[0], self.dim[0] - 2)
Ejemplo n.º 8
0
 def test_radius_of_gyration_empty(self):
     cy.clear_array(tst_dimL(), self.arr)
     com = center_of_mass(tst_dimL(), self.arr)
     self.assertEqual(None, com)
     Rg = radius_of_gyration(com, tst_dimL(), self.arr)
     self.assertEqual(0, Rg)