def test_disable_update_anoms(self): orb = Orbit(M0=self.M, G=self.G, direct_update=False, auto_update=False, **self.cart_orb) orb.calculate_kepler() mu0 = orb.mean_anomaly orb.x += 0.1 mu = orb.mean_anomaly nt.assert_array_equal(mu0, mu) mu0 = orb.mean_anomaly nu0 = orb.anom orb.vx -= 3 orb.calculate_kepler() mu = orb.mean_anomaly nu = orb.anom with self.assertRaises(AssertionError): nt.assert_array_equal(mu0, mu) with self.assertRaises(AssertionError): nt.assert_array_equal(nu0, nu) nu0 = orb.anom cart0 = orb.cartesian orb.mean_anomaly = 0 nu = orb.anom cart = orb.cartesian with self.assertRaises(AssertionError): nt.assert_array_equal(nu0, nu) nt.assert_array_equal(cart0, cart)
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)