From 5e1e43c9f0d8b488d0f1b5c4b85862e628a4f762 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 29 Jun 2023 18:06:28 +0200 Subject: null: add a test for coord_similarity() --- test/test_null.npz | Bin 24506 -> 53198 bytes test/test_null.py | 27 ++++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/test/test_null.npz b/test/test_null.npz index d970af4..645c102 100644 Binary files a/test/test_null.npz and b/test/test_null.npz differ diff --git a/test/test_null.py b/test/test_null.py index 56c3031..c556c56 100644 --- a/test/test_null.py +++ b/test/test_null.py @@ -2,7 +2,9 @@ import os from unittest import TestCase import numpy as np -from numpy.testing import assert_allclose +from numpy.testing import assert_allclose, assert_equal + +from scipy.integrate import cumulative_trapezoid from math_utils.array_utils import array_reflect as ar from nr_analysis_axi import null, invars @@ -24,3 +26,26 @@ class TestNull(TestCase): l = self.data['l'] assert_allclose(g(l), self.data['g'], 1e-12) + + def test_coord_similarity(self): + lapse_origin = np.sqrt(-self.data['gtt'][:, 0]) + tau = ar(cumulative_trapezoid(lapse_origin, self.data['t'], initial = 0.0), -1) + T_null = -np.log(5.4 - tau) + + g = null.null_geodesics(self.t, self.x, self.gxx, self.gtt) + + lambda_max = 0.01 + ret = null.coord_similarity(self.t, self.x, T_null, None, None, g = g, + lambda_max = lambda_max, lambda_points = 32) + + # returned T_null should be the same as source in this case + assert_equal(ret[0], T_null) + + # lambdas are from 0 - lambda_max + assert_allclose(ret[1][0], 0.0, 1e-12) + assert_allclose(ret[1][-1], lambda_max, 1e-12) + # lambdas are equidistant + assert_allclose(ret[1][1:] - ret[1][:-1], ret[1][1], 1e-12) + + assert_allclose(ret[2][:-10], self.data['x_of_Tnull_lambda'], 1e-12) + assert_allclose(ret[3][:-10], self.data['t_of_Tnull_lambda'], 1e-12) -- cgit v1.2.3