Skip to content

Commit 3624566

Browse files
authored
Implement size check for photon array
Add error handling for photon array size exceeding limit
1 parent b1329d7 commit 3624566

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

jax_galsim/photon_array.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ def __init__(
9393
self._Ntot = _JAX_GALSIM_PHOTON_ARRAY_SIZE or N
9494
self._Ntot = cast_to_int(self._Ntot)
9595

96+
if _JAX_GALSIM_PHOTON_ARRAY_SIZE is not None:
97+
equinox.error_if(
98+
jnp.array(N),
99+
jnp.array(N > _JAX_GALSIM_PHOTON_ARRAY_SIZE),
100+
f"The given photon array size {N} is larger than "
101+
f"the allowed total size {_JAX_GALSIM_PHOTON_ARRAY_SIZE}.",
102+
)
103+
96104
if _nokeep is not None:
97105
self._nokeep = _nokeep
98106
else:

0 commit comments

Comments
 (0)