Skip to content

Commit a7e2300

Browse files
committed
fix: enable index check for photon arrays
1 parent 1f0d1da commit a7e2300

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

jax_galsim/photon_array.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,24 @@ def copyFrom(
561561
do_flux=True,
562562
do_other=True,
563563
):
564+
# jax naturally checks the other error cases in the test suite with the `.at`
565+
# syntax, but it does not check out of bounds inds like ints so we do that here
566+
if isinstance(target_indices, int) and (
567+
target_indices < -self._nokeep.shape[0]
568+
or target_indices >= self._nokeep.shape[0]
569+
):
570+
raise ValueError(
571+
f"target_indices is invalid for the target PhotonArray. Got {target_indices!r}"
572+
)
573+
574+
if isinstance(source_indices, int) and (
575+
source_indices < -rhs._nokeep.shape[0]
576+
or source_indices >= rhs._nokeep.shape[0]
577+
):
578+
raise ValueError(
579+
f"source_indices is invalid for the source PhotonArray. Got {source_indices!r}"
580+
)
581+
564582
return self._copyFrom(
565583
rhs, target_indices, source_indices, do_xy, do_flux, do_other
566584
)

tests/GalSim

0 commit comments

Comments
 (0)