Skip to content

Commit 1f0d1da

Browse files
committed
fix: use any everywhere
1 parent 6d40f5a commit 1f0d1da

4 files changed

Lines changed: 18 additions & 13 deletions

File tree

jax_galsim/gsobject.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,13 @@ def drawImage(
629629
raise TypeError("image is not an Image instance", image)
630630

631631
# Make sure (gain, area, exptime) have valid values:
632-
gain = equinox.error_if(jnp.array(gain), gain <= 0.0, "Invalid gain <= 0.")
633-
area = equinox.error_if(jnp.array(area), area <= 0.0, "Invalid area <= 0.")
632+
gain = jnp.array(gain)
633+
gain = equinox.error_if(gain, jnp.any(gain <= 0.0), "Invalid gain <= 0.")
634+
area = jnp.array(area)
635+
area = equinox.error_if(area, jnp.any(area <= 0.0), "Invalid area <= 0.")
636+
exptime = jnp.array(exptime)
634637
exptime = equinox.error_if(
635-
jnp.array(exptime), exptime <= 0.0, "Invalid exptime <= 0."
638+
exptime, jnp.any(exptime <= 0.0), "Invalid exptime <= 0."
636639
)
637640

638641
if method == "phot" and save_photons and maxN is not None:
@@ -1228,7 +1231,8 @@ def drawPhot(
12281231
elif not isinstance(sensor, Sensor):
12291232
raise TypeError("The sensor provided is not a Sensor instance")
12301233

1231-
gain = equinox.error_if(jnp.array(gain), gain <= 0.0, "Invalid gain <= 0.")
1234+
gain = jnp.array(gain)
1235+
gain = equinox.error_if(gain, jnp.any(gain <= 0.0), "Invalid gain <= 0.")
12321236

12331237
if n_photons is not None:
12341238
# n_photons is the length of an array so it is a python int and

jax_galsim/integ.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ def _base_integration():
7575

7676
return equinox.error_if(
7777
val,
78-
status != 0,
78+
jnp.any(status != 0),
7979
"`jax_galsim.int1d` failed to converge!",
8080
)

jax_galsim/interpolatedimage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,10 @@ def __init__(
515515
)
516516

517517
if calculate_stepk or calculate_maxk or flux is not None:
518+
image.array = jnp.array(image.array)
518519
image.array = equinox.error_if(
519-
jnp.array(image.array),
520-
image.array.sum() == 0.0,
520+
image.array,
521+
jnp.any(image.array.sum() == 0.0),
521522
"This input image has zero total flux. It does not define a "
522523
"valid surface brightness profile.",
523524
)

jax_galsim/shear.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(self, *args, **kwargs):
5353
self._g = g1 + 1j * g2
5454
self._g = equinox.error_if(
5555
self._g,
56-
jnp.abs(self._g) > 1.0,
56+
jnp.any(jnp.abs(self._g) > 1.0),
5757
"Requested shear exceeds 1.",
5858
)
5959

@@ -64,7 +64,7 @@ def __init__(self, *args, **kwargs):
6464
absesq = e1**2 + e2**2
6565
absesq = equinox.error_if(
6666
absesq,
67-
absesq > 1.0,
67+
jnp.any(absesq > 1.0),
6868
"Requested distortion exceeds 1.",
6969
)
7070
self._g = (e1 + 1j * e2) * self._e2g(absesq)
@@ -91,7 +91,7 @@ def __init__(self, *args, **kwargs):
9191
g = jnp.array(kwargs.pop("g"))
9292
g = equinox.error_if(
9393
g,
94-
g > 1 or g < 0,
94+
jnp.any((g > 1) | (g < 0)),
9595
"Requested |shear| is outside [0,1].",
9696
)
9797
self._g = g * jnp.exp(2j * beta.rad)
@@ -110,7 +110,7 @@ def __init__(self, *args, **kwargs):
110110
e = jnp.array(kwargs.pop("e"))
111111
e = equinox.error_if(
112112
e,
113-
(e > 1) | (e < 0),
113+
jnp.any((e > 1) | (e < 0)),
114114
"Requested distortion is outside [0,1].",
115115
)
116116
self._g = self._e2g(e**2) * e * jnp.exp(2j * beta.rad)
@@ -129,7 +129,7 @@ def __init__(self, *args, **kwargs):
129129
eta = jnp.array(kwargs.pop("eta"))
130130
eta = equinox.error_if(
131131
eta,
132-
eta < 0,
132+
jnp.any(eta < 0),
133133
"Requested eta is below 0.",
134134
)
135135
self._g = self._eta2g(eta) * eta * jnp.exp(2j * beta.rad)
@@ -148,7 +148,7 @@ def __init__(self, *args, **kwargs):
148148
q = jnp.array(kwargs.pop("q"))
149149
q = equinox.error_if(
150150
q,
151-
(q <= 0) | (q > 1),
151+
jnp.any((q <= 0) | (q > 1)),
152152
"Cannot use requested axis ratio.",
153153
)
154154
eta = -jnp.log(q)

0 commit comments

Comments
 (0)