summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-06-29 18:06:28 +0200
committerAnton Khirnov <anton@khirnov.net>2023-06-29 18:06:28 +0200
commit5e1e43c9f0d8b488d0f1b5c4b85862e628a4f762 (patch)
tree8884ffde38e08d80a7629d73beb7e6fa238ca760
parente48368e02fa618e8db5eb384bb487fd3c740660f (diff)
null: add a test for coord_similarity()
-rw-r--r--test/test_null.npzbin24506 -> 53198 bytes
-rw-r--r--test/test_null.py27
2 files changed, 26 insertions, 1 deletions
diff --git a/test/test_null.npz b/test/test_null.npz
index d970af4..645c102 100644
--- a/test/test_null.npz
+++ b/test/test_null.npz
Binary files 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)