Skip to content

Commit baa412b

Browse files
committed
add error catch tests to CI
1 parent 64d5586 commit baa412b

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

tests/test_spherical_transform.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,55 @@ def test_transform_forward_healpix(
180180
flm = hp.sphtfunc.map2alm(f, lmax=L - 1, iter=0)
181181

182182
np.testing.assert_allclose(flm, flm_check, atol=1e-14)
183+
184+
185+
def test_spin_exceptions(flm_generator):
186+
spin = 10
187+
L = 16
188+
sampling = "mw"
189+
190+
flm = flm_generator(L=L, reality=False)
191+
f = spherical.inverse(flm, L, spin=0, sampling=sampling, method="jax_ssht")
192+
193+
with pytest.raises(Warning) as e:
194+
spherical.inverse(flm, L, spin=spin, sampling=sampling, method="jax")
195+
196+
with pytest.raises(Warning) as e:
197+
spherical.forward(f, L, spin=spin, sampling=sampling, method="jax")
198+
199+
200+
def test_sampling_ssht_backend_exceptions(flm_generator):
201+
sampling = "healpix"
202+
nside = 6
203+
L = 2 * nside
204+
205+
flm = flm_generator(L=L, reality=False)
206+
f = spherical.inverse(flm, L, 0, nside, sampling, "jax_healpy")
207+
208+
with pytest.raises(ValueError) as e:
209+
spherical.inverse(flm, L, 0, nside, sampling, "jax_ssht")
210+
211+
with pytest.raises(ValueError) as e:
212+
spherical.forward(f, L, 0, nside, sampling, "jax_ssht")
213+
214+
215+
def test_sampling_healpy_backend_exceptions(flm_generator):
216+
sampling = "mw"
217+
L = 12
218+
219+
flm = flm_generator(L=L, reality=False)
220+
f = spherical.inverse(flm, L, 0, None, sampling, "jax_ssht")
221+
222+
with pytest.raises(ValueError) as e:
223+
spherical.inverse(flm, L, 0, None, sampling, "jax_healpy")
224+
225+
with pytest.raises(ValueError) as e:
226+
spherical.forward(f, L, 0, None, sampling, "jax_healpy")
227+
228+
229+
def test_sampling_exceptions(flm_generator):
230+
with pytest.raises(ValueError) as e:
231+
spherical.inverse(None, 0, 0, None, method="incorrect")
232+
233+
with pytest.raises(ValueError) as e:
234+
spherical.forward(None, 0, 0, None, method="incorrect")

tests/test_wigner_transform.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,29 @@ def test_ssht_c_backend_forward_wigner_transform(
132132
f, L, N, None, sampling, "jax_ssht", reality, L_lower=L_lower
133133
)
134134
np.testing.assert_allclose(flmn, flmn_check, atol=1e-12)
135+
136+
137+
def test_N_exceptions(flmn_generator):
138+
N = 10
139+
L = 16
140+
flmn = flmn_generator(L=L, N=N)
141+
f = base_wigner.inverse(flmn, L, N)
142+
143+
with pytest.raises(Warning) as e:
144+
wigner.inverse(flmn, L, N)
145+
146+
with pytest.raises(Warning) as e:
147+
wigner.forward(f, L, N)
148+
149+
150+
def test_sampling_ssht_backend_exceptions(flmn_generator):
151+
L = 16
152+
N = 1
153+
flmn = flmn_generator(L=L, N=N)
154+
f = base_wigner.inverse(flmn, L, N)
155+
156+
with pytest.raises(ValueError) as e:
157+
wigner.inverse(flmn, L, N, sampling="healpix", method="jax_ssht")
158+
159+
with pytest.raises(ValueError) as e:
160+
wigner.forward(f, L, N, sampling="healpix", method="jax_ssht")

0 commit comments

Comments
 (0)