Skip to content

Commit 3ee5f33

Browse files
committed
fix+doc: do more error checking and more docs
1 parent 2ef7195 commit 3ee5f33

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

jax_galsim/gsobject.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,10 +1115,10 @@ def _calculate_nphotons(self, n_photons, poisson_flux, max_extra_noise, rng):
11151115
lax_description="""\
11161116
The JAX-GalSim version of ``makePhot``
11171117
1118-
- does little to no error checking on the inputs
11191118
- uses a default of ``n_photons=None`` instead of ``n_photons=0``
1120-
to indicate that the number of photons should be determined
1121-
from the flux and gain
1119+
- uses a default of ``max_extra_noise=None`` instead of ``max_extra_noise=0``
1120+
to indicate no limit on the extra noise
1121+
- raises generic ``Exception``s instead of more specific exceptions for some invalid inputs
11221122
""",
11231123
)
11241124
def makePhot(
@@ -1187,6 +1187,9 @@ def makePhot(
11871187
- uses a default of ``n_photons=None`` instead of ``n_photons=0``
11881188
to indicate that the number of photons should be determined
11891189
from the flux and gain
1190+
- uses a default of ``max_extra_noise=None`` instead of ``max_extra_noise=0``
1191+
to indicate no limit on the extra noise
1192+
- raises generic ``Exception``s instead of more specific exceptions for some invalid inputs
11901193
- requires that the ``maxN`` option must be a constant
11911194
""",
11921195
)
@@ -1227,6 +1230,8 @@ def drawPhot(
12271230
elif not isinstance(sensor, Sensor):
12281231
raise TypeError("The sensor provided is not a Sensor instance")
12291232

1233+
gain = equinox.error_if(jnp.array(gain), gain <= 0.0, "Invalid gain <= 0.")
1234+
12301235
if n_photons is not None:
12311236
# n_photons is the length of an array so it is a python int and
12321237
# and thus a constant wrt to JIT

0 commit comments

Comments
 (0)