Skip to content

Commit 8908da6

Browse files
Jammy2211Jammy2211
authored andcommitted
fix image mesh adapt code
1 parent f2a0dd2 commit 8908da6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

autoarray/inversion/pixelization/mesh/rectangular.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,16 @@ def mesh_weight_map_from(self, adapt_data, xp=np) -> np.ndarray:
205205
"""
206206
mesh_weight_map = xp.asarray(adapt_data.array)
207207
mesh_weight_map = xp.clip(mesh_weight_map, 1e-12, None)
208-
mesh_weight_map = mesh_weight_map**self.weight_power
209-
mesh_weight_map[mesh_weight_map < self.weight_floor] = self.weight_floor
210-
mesh_weight_map /= xp.sum(mesh_weight_map)
208+
mesh_weight_map = mesh_weight_map ** self.weight_power
209+
210+
# Apply floor using xp.where (safe for NumPy and JAX)
211+
mesh_weight_map = xp.where(
212+
mesh_weight_map < self.weight_floor,
213+
self.weight_floor,
214+
mesh_weight_map,
215+
)
216+
217+
# Normalize
218+
mesh_weight_map = mesh_weight_map / xp.sum(mesh_weight_map)
219+
211220
return mesh_weight_map

0 commit comments

Comments
 (0)