|
12 | 12 | ############################################################################## |
13 | 13 | # IMPORTS |
14 | 14 |
|
15 | | -# BUILT-IN |
16 | | -import pathlib |
17 | | - |
18 | 15 | # THIRD PARTY |
19 | | -# import matplotlib.pyplot as plt |
20 | 16 | import numpy as np |
21 | 17 |
|
22 | | -# import pytest |
23 | | -# from astropy.utils.misc import NumpyRNGContext |
24 | | -# from galpy.df import isotropicHernquistdf |
25 | | -from galpy.potential import HernquistPotential, SCFPotential |
26 | | - |
27 | | -# LOCAL |
28 | | -# from sample_scf.sample_exact import SCFPhiSampler, SCFRSampler, SCFSampler, SCFThetaSampler |
29 | | -from sample_scf.utils import zeta_of_r # x_of_theta |
30 | | - |
31 | | -# from .test_base import SCFSamplerTestBase |
32 | | -# from sample_scf import sample_exact |
33 | | - |
34 | | - |
35 | 18 | ############################################################################## |
36 | 19 | # PARAMETERS |
37 | 20 |
|
38 | | -# hernpot = TriaxialHernquistPotential(b=0.8, c=1.2) |
39 | | -hernpot = HernquistPotential() |
40 | | -coeffs = np.load(pathlib.Path(__file__).parent / "scf_coeffs.npz") |
41 | | -Acos, Asin = coeffs["Acos"], coeffs["Asin"] |
42 | | - |
43 | | -pot = SCFPotential(Acos=Acos, Asin=Asin) |
44 | | -pot.turn_physical_off() |
| 21 | +rgrid = np.concatenate(([0], np.geomspace(1e-1, 1e3, 100))) |
| 22 | +tgrid = np.linspace(-np.pi / 2, np.pi / 2, 30) |
| 23 | +pgrid = np.linspace(0, 2 * np.pi, 30) |
45 | 24 |
|
46 | | -# r sampling |
47 | | -r = np.unique(np.concatenate([[0], np.geomspace(1e-7, 1e3, 100), [np.inf]])) |
48 | | -zeta = zeta_of_r(r) |
49 | | -m = [pot._mass(x) for x in r] |
50 | | -m[0] = 0 |
51 | | -m[-1] = 1 |
52 | | - |
53 | | -# theta sampling |
54 | | -theta = np.linspace(-np.pi / 2, np.pi / 2, 30) |
55 | | - |
56 | | -# phi sampling |
57 | | -phi = np.linspace(0, 2 * np.pi, 30) |
58 | 25 |
|
59 | 26 | ############################################################################## |
60 | 27 | # CODE |
61 | 28 | ############################################################################## |
62 | 29 |
|
63 | 30 |
|
64 | 31 | # class Test_SCFSampler(SCFSamplerTestBase): |
65 | | -# """Test :class:`sample_scf.sample_intrp.SCFSampler`.""" |
| 32 | +# """Test :class:`sample_scf.sample_exact.SCFSampler`.""" |
| 33 | +# |
| 34 | +# self.cls = sample_intrp.SCFSampler |
| 35 | +# self.cls_args = (rgrid, tgrid, pgrid) |
| 36 | +# self.cls_kwargs = {} |
| 37 | +# |
| 38 | +# self.expected_rvs = { |
| 39 | +# 0: dict(r=2.8583146808697, theta=1.473013568997 * u.rad, phi=3.4482969442579 * u.rad), |
| 40 | +# 1: dict(r=2.8583146808697, theta=1.473013568997 * u.rad, phi=3.4482969442579 * u.rad), |
| 41 | +# 2: dict( |
| 42 | +# r=[59.15672032022, 2.842480998054, 71.71466505664, 5.471148006362], |
| 43 | +# theta=[0.36517953566424, 1.4761907683040, 0.33207251545636, 1.1267111320704] |
| 44 | +# * u.rad, |
| 45 | +# phi=[6.076027676095, 3.438361627636, 6.11155607905, 4.491321348792] * u.rad, |
| 46 | +# ), |
| 47 | +# } |
66 | 48 | # |
67 | | -# def setup_class(self): |
68 | | -# super().setup_class() |
| 49 | +# # =============================================================== |
| 50 | +# # Method Tests |
69 | 51 | # |
70 | | -# self.cls = sample_exact.SCFSampler |
71 | | -# self.cls_args = () |
| 52 | +# # TODO! make sure these are correct |
| 53 | +# @pytest.mark.parametrize( |
| 54 | +# "r, theta, phi, expected", |
| 55 | +# [ |
| 56 | +# (0, 0, 0, [0, 0.5, 0]), |
| 57 | +# (1, 0, 0, [0.25, 0.5, 0]), |
| 58 | +# ([0, 1], [0, 0], [0, 0], [[0, 0.5, 0], [0.25, 0.5, 0]]), |
| 59 | +# ], |
| 60 | +# ) |
| 61 | +# def test_cdf(self, sampler, r, theta, phi, expected): |
| 62 | +# """Test :meth:`sample_scf.base.SCFSamplerBase.cdf`.""" |
| 63 | +# assert np.allclose(sampler.cdf(r, theta, phi), expected, atol=1e-16) |
72 | 64 | # |
73 | 65 | # # /def |
74 | 66 | # |
|
0 commit comments