Esempio n. 1
0
    def test_subset_rect(self):
        t = oh.read_output('test_bodies.out')
        tc = t.copy()

        tc.subset_rect(('x',), ((-1,1),))

        self.assertTrue(len(tc) == 7)
Esempio n. 2
0
    def test_calcs(self): #makes sure that the values that
        #are not initially calculated on instantiation then run when the user
        #tries to get those values

        t = oh.read_output('test_bodies.out')

        self.assertTrue(len(t.pmra) == len(t))
        self.assertTrue(len(t.energy) == len(t))
Esempio n. 3
0
    def test_append_point(self):
        t = oh.read_output('test_bodies.out')

        t2 = t.copy()

        t2.append_point(t, 5)

        self.assertTrue(t.x[5] == t2.x[-1])
        self.assertTrue(len(t2) == len(t)+1)
Esempio n. 4
0
    def test_copy(self):
        t = oh.read_output('test_bodies.out')

        t2 = t.copy()
        test = t.x[0]
        t.x[0] = 0

        self.assertTrue(t.x[0] != t2.x[0])
        self.assertTrue(t2.x[0] == test)
Esempio n. 5
0
    def test_timestep_iter(self):
        t = oh.read_output('test_bodies.out')

        for key, k in zip(t, t.index_list):
            self.assertTrue(t[key][0] == t[k][0])
            t[key][0] = 1

        self.assertTrue(t.x[0] == t['x'][0] == 1)

        for key in t:
            t[key] = np.append(t[key], 0)

        self.assertTrue(t.x[-1] == t['x'][-1] == 0)
Esempio n. 6
0
    def test_update(self):
        t = oh.read_output('test_bodies.out')
        t.update(force=True)

        #these values for the COM's are hard coded, unfortunately. But they are correct.
        self.assertTrue(len(t.center_of_mass) == 3)
        self.assertTrue(round(abs(t.center_of_mass[0] - 0.7835947518080879) + abs(t.center_of_mass[1] - 0.2947546230649471) + abs(t.center_of_mass[2] + 0.1318053758650839), prec) == 0)

        self.assertTrue(len(t.center_of_momentum) == 3)
        self.assertTrue(round(abs(t.center_of_momentum[0] - 6.001115213580641) + abs(t.center_of_momentum[1] + 65.29652414026405) + abs(t.center_of_momentum[2] + 26.462554427407223), prec) == 0)

        self.assertTrue(len(t.distFromCOM) == len(t))
        self.assertTrue(round(abs(t.distFromCOM[0] - ((t.center_of_mass[0] - t.x[0])**2 + (t.center_of_mass[1] - t.y[0])**2 + (t.center_of_mass[2] - t.z[0])**2)**0.5), prec) == 0)
Esempio n. 7
0
    def test_split(self):
        t = oh.read_output('test_bodies.out')

        t1, t2 = t.split(5)
        self.assertTrue(t1.x[0] == t.x[0])
        self.assertTrue(t2.x[0] == t.x[5])
Esempio n. 8
0
    def test_timestep_dict(self):
        t = oh.read_output('test_bodies.out')
        self.assertTrue(t.x[0] == t['x'][0])

        t.x[0] = 1
        self.assertTrue(t['x'][0] == 1)
Esempio n. 9
0
 def test_timestep_initialize(self):
     t = Timestep() #check default initialization
     t = oh.read_output('test_bodies.out') #check loading from a file