File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from functools import partial
22
3+ import equinox
34import galsim as _galsim
45import jax
56import jax .numpy as jnp
@@ -31,7 +32,7 @@ def _Knu(nu, x):
3132 lax_description = """\
3233 The JAX-GalSim version of the Moffat profile
3334
34- - does not support truncation or beta < 1.1
35+ - does not support truncation or beta <= 1.1
3536- does not support gsparams.maxk_thresholds > 0.1
3637- does not support autodiff with respect to the `beta` parameter
3738 for Fourier-space evaluations
@@ -67,6 +68,18 @@ def __init__(
6768 f"(got trunc={ repr (trunc )} , always pass the constant 0.0)!"
6869 )
6970
71+ if isinstance (beta , (float , int )):
72+ if beta <= self ._beta_thr :
73+ raise ValueError (
74+ f"JAX-GalSim does not support Moffat beta values <= { self ._beta_thr } ."
75+ )
76+ else :
77+ beta = equinox .error_if (
78+ jnp .array (beta ),
79+ beta <= self ._beta_thr ,
80+ f"JAX-GalSim does not support Moffat beta values <= { self ._beta_thr } ." ,
81+ )
82+
7083 # Parse the radius options
7184 if half_light_radius is not None :
7285 if scale_radius is not None or fwhm is not None :
Original file line number Diff line number Diff line change 1+ import jax
2+ import jax .numpy as jnp
3+ import pytest
4+
5+ import jax_galsim
6+
7+
8+ def test_moffat_jax_beta_raises ():
9+
10+ @jax .jit
11+ def make_moffat (beta ):
12+ return jax_galsim .Moffat (beta , fwhm = 1.0 )
13+
14+ with pytest .raises (Exception ):
15+ make_moffat (jnp .array (1.1 ))
16+
17+ with pytest .raises (Exception ):
18+ make_moffat (0.9 )
You can’t perform that action at this time.
0 commit comments