def test_one_mode(self): """ An example of a test """ grav_220 = qnm.modes_cache(s=-2, l=2, m=2, n=0) omega, A, C = grav_220(a=0.68) assert np.allclose(omega, (0.5239751042900845 - 0.08151262363119974j))
def test_interp_only(self): """Check that we get reasonable values (but not identical!) with just interpolation. """ grav_220 = qnm.modes_cache(s=-2, l=2, m=2, n=0) a = 0.68 assert a not in grav_220.a omega_int, A_int, C_int = grav_220(a=a, interp_only=True) omega_sol, A_sol, C_sol = grav_220(a=a, interp_only=False, store=False) assert np.allclose(omega_int, omega_sol) and not np.equal(omega_int, omega_sol) assert np.allclose(A_int, A_sol) and not np.equal(A_int, A_sol) assert np.allclose(C_int, C_sol) and not all(np.equal(C_int, C_sol))
def test_store_a(self): """Check that the option store=True updates a spin sequence""" grav_220 = qnm.modes_cache(s=-2, l=2, m=2, n=0) old_n = len(grav_220.a) k = int(old_n / 2) new_a = 0.5 * (grav_220.a[k] + grav_220.a[k + 1]) assert new_a not in grav_220.a _, _, _ = grav_220(new_a, store=False) n_1 = len(grav_220.a) assert old_n == n_1 _, _, _ = grav_220(new_a, store=True) n_2 = len(grav_220.a) assert n_2 == n_1 + 1
def test_resolve(self): """Test that option resolve_if_found=True really does a new solve""" grav_220 = qnm.modes_cache(s=-2, l=2, m=2, n=0) n = len(grav_220.a) k = int(n / 2) a = grav_220.a[k] grav_220.solver.solved = False omega_old, A_old, C_old = grav_220(a=a, resolve_if_found=False) solved_1 = grav_220.solver.solved omega_new, A_new, C_new = grav_220(a=a, resolve_if_found=True) solved_2 = grav_220.solver.solved assert (solved_1 is False) and (solved_2 is True) assert np.allclose(omega_new, omega_old) assert np.allclose(A_new, A_old) assert np.allclose(C_new, C_old)
def test_mirror_mode_transformation(self, s, l, m, n, a): import copy mode = qnm.modes_cache(s=s, l=l, m=m, n=n) om, A, C = mode(a=a) solver = copy.deepcopy( mode.solver ) # need to import copy -- don't want to actually modify this mode's solver solver.clear_results() solver.set_params(a=a, m=-m, A_closest_to=A.conj(), omega_guess=-om.conj()) om_prime = solver.do_solve() assert np.allclose(-om.conj(), solver.omega) assert np.allclose(A.conj(), solver.A) assert np.allclose( (-1)**(l + qnm.angular.ells(s, m, mode.l_max)) * C.conj(), solver.C)
def test_resolve(self): """Test that option resolve_if_found=True really does a new solve""" grav_220 = qnm.modes_cache(s=-2, l=2, m=2, n=0) n = len(grav_220.a) k = int(n / 2) a = grav_220.a[k] omega_old, A_old, C_old = grav_220(a=a, resolve_if_found=False) old_tol = grav_220.solver.tol old_cf_tol = grav_220.solver.cf_tol grav_220.solver.set_params(tol=old_tol * 0.1, cf_tol=old_cf_tol * 0.1) omega_new, A_new, C_new = grav_220(a=a, resolve_if_found=True) assert np.allclose(omega_new, omega_old) and not np.equal(omega_new, omega_old) assert np.allclose(A_new, A_old) and not np.equal(A_new, A_old) assert np.allclose(C_new, C_old) and not all(np.equal(C_new, C_old))