Skip to content

Commit 21ccc39

Browse files
Jammy2211Jammy2211
authored andcommitted
remove more xp.asarray
1 parent 1d8aba1 commit 21ccc39

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

autoarray/fit/fit_util.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def residual_map_with_mask_from(
198198
model_data
199199
The model data used to fit the data.
200200
"""
201-
return xp.where(xp.asarray(mask) == 0, xp.subtract(data, model_data), 0)
201+
return xp.where(mask == 0, xp.subtract(data, model_data), 0)
202202

203203

204204
@to_new_array
@@ -221,7 +221,7 @@ def normalized_residual_map_with_mask_from(
221221
mask
222222
The mask applied to the residual-map, where `False` entries are included in the calculation.
223223
"""
224-
return xp.where(xp.asarray(mask) == 0, xp.divide(residual_map, noise_map), 0)
224+
return xp.where(mask == 0, xp.divide(residual_map, noise_map), 0)
225225

226226

227227
@to_new_array
@@ -244,7 +244,7 @@ def chi_squared_map_with_mask_from(
244244
mask
245245
The mask applied to the residual-map, where `False` entries are included in the calculation.
246246
"""
247-
return xp.where(xp.asarray(mask) == 0, xp.square(residual_map / noise_map), 0)
247+
return xp.where(mask == 0, xp.square(residual_map / noise_map), 0)
248248

249249

250250
def chi_squared_with_mask_from(
@@ -263,7 +263,7 @@ def chi_squared_with_mask_from(
263263
mask
264264
The mask applied to the chi-squared-map, where `False` entries are included in the calculation.
265265
"""
266-
return float(xp.sum(chi_squared_map[xp.asarray(mask) == 0]))
266+
return float(xp.sum(chi_squared_map[mask == 0]))
267267

268268

269269
def chi_squared_with_mask_fast_from(
@@ -301,8 +301,8 @@ def chi_squared_with_mask_fast_from(
301301
xp.subtract(
302302
data,
303303
model_data,
304-
)[xp.asarray(mask) == 0],
305-
noise_map[xp.asarray(mask) == 0],
304+
)[mask == 0],
305+
noise_map[mask == 0],
306306
)
307307
)
308308
)
@@ -326,7 +326,7 @@ def noise_normalization_with_mask_from(
326326
mask
327327
The mask applied to the noise-map, where `False` entries are included in the calculation.
328328
"""
329-
return float(xp.sum(xp.log(2 * xp.pi * noise_map[xp.asarray(mask) == 0] ** 2.0)))
329+
return float(xp.sum(xp.log(2 * xp.pi * noise_map[mask == 0] ** 2.0)))
330330

331331

332332
def chi_squared_with_noise_covariance_from(

autoarray/inversion/pixelization/mesh/rectangular.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def mesh_weight_map_from(self, adapt_data, xp=np) -> np.ndarray:
208208
xp
209209
The array library to use.
210210
"""
211-
mesh_weight_map = xp.asarray(adapt_data.array)
211+
mesh_weight_map = adapt_data.array
212212
mesh_weight_map = xp.clip(mesh_weight_map, 1e-12, None)
213213
mesh_weight_map = mesh_weight_map**self.weight_power
214214

autoarray/inversion/regularization/gaussian_kernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def gauss_cov_matrix_from(
3333
The Gaussian covariance matrix.
3434
"""
3535
# Ensure array:
36-
pts = xp.asarray(pixel_points) # (N, 2)
36+
pts = pixel_points # (N, 2)
3737
# Compute squared distances: ||p_i - p_j||^2
3838
diffs = pts[:, None, :] - pts[None, :, :] # (N, N, 2)
3939
d2 = xp.sum(diffs**2, axis=-1) # (N, N)

0 commit comments

Comments
 (0)