def test_mass(self): orb1 = Orbit(M0=self.M, G=self.G, m=0.1, **self.kep_orb) orb2 = Orbit(M0=self.M, G=self.G, m=0.0, **self.kep_orb) with self.assertRaises(AssertionError): nt.assert_array_almost_equal(orb1.cartesian, orb2.cartesian) orb1.m[:] = 0 orb1.calculate_cartesian() nt.assert_array_almost_equal(orb1.cartesian, orb2.cartesian)
def test_disable_update(self): orb = Orbit(M0=self.M, G=self.G, direct_update=False, auto_update=False, **self.cart_orb) assert np.all(np.isnan(orb.kepler)) orb.x += 1 assert np.all(np.isnan(orb.kepler)) orb.calculate_kepler() kep0 = orb.kepler print('Before cart change') print(orb) orb.x += 1 kep = orb.kepler print('After cart change') print(orb) nt.assert_array_equal(kep0, kep) orb = Orbit(M0=self.M, G=self.G, direct_update=False, auto_update=False, **self.kep_orb) assert np.all(np.isnan(orb.cartesian)) orb.a += 1 assert np.all(np.isnan(orb.cartesian)) orb.a = 1 orb.calculate_cartesian() cart0 = orb.cartesian print('Before kep change') print(orb) orb.a += 1 cart = orb.cartesian print('After kep change') print(orb) nt.assert_array_equal(cart0, cart)