Skip to content

Commit 1d8aba1

Browse files
Jammy2211Jammy2211
authored andcommitted
all use tuple and removed pointless xp.asarray
1 parent 9e8733e commit 1d8aba1

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

autoarray/structures/arrays/kernel_2d.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -673,16 +673,12 @@ def convolved_image_from(self, image, blurring_image, jax_method="direct", xp=np
673673
# start with native image padded with zeros
674674
image_both_native = xp.zeros(image.mask.shape, dtype=image.dtype)
675675

676-
image_both_native = image_both_native.at[image.mask.slim_to_native_tuple].set(
677-
xp.asarray(image.array)
678-
)
676+
image_both_native = image_both_native.at[image.mask.slim_to_native_tuple].set(image.array)
679677

680678
# add blurring contribution if provided
681679
if blurring_image is not None:
682680

683-
image_both_native = image_both_native.at[blurring_image.mask.slim_to_native_tuple].set(
684-
xp.asarray(blurring_image.array)
685-
)
681+
image_both_native = image_both_native.at[blurring_image.mask.slim_to_native_tuple].set(blurring_image.array)
686682

687683
else:
688684
warnings.warn(
@@ -846,7 +842,7 @@ def convolved_mapping_matrix_from(
846842
)
847843

848844
# return slim form
849-
return blurred_mapping_matrix_native[slim_to_native_tuple]
845+
return blurred_mapping_matrix_native[mask.slim_to_native_tuple]
850846

851847
def rescaled_with_odd_dimensions_from(
852848
self, rescale_factor: float, normalize: bool = False
@@ -983,19 +979,16 @@ def convolved_image_via_real_space_from(
983979
import jax
984980

985981
# start with native array padded with zeros
986-
image_native = xp.zeros(image.mask.shape, dtype=xp.asarray(image.array).dtype)
982+
image_native = xp.zeros(image.mask.shape, dtype=image.array.dtype)
987983

988984
# set image pixels
989-
image_native = image_native.at[image.mask.slim_to_native_tuple].set(
990-
xp.asarray(image.array)
991-
)
985+
image_native = image_native.at[image.mask.slim_to_native_tuple].set(image.array)
992986

993987
# add blurring contribution if provided
994988
if blurring_image is not None:
995989

996-
image_native = image_native.at[blurring_image.mask.slim_to_native_tuple].set(
997-
xp.asarray(blurring_image.array)
998-
)
990+
image_native = image_native.at[blurring_image.mask.slim_to_native_tuple].set(blurring_image.array)
991+
999992
else:
1000993
warnings.warn(
1001994
"No blurring_image provided. Only the direct image will be convolved. "
@@ -1113,17 +1106,16 @@ def convolved_image_via_real_space_np_from(
11131106
from scipy.signal import convolve as scipy_convolve
11141107

11151108
# start with native array padded with zeros
1116-
image_native = xp.zeros(image.mask.shape, dtype=xp.asarray(image.array).dtype)
1109+
image_native = xp.zeros(image.mask.shape, dtype=image.array.dtype)
11171110

11181111
# set image pixels
1119-
image_native[image.mask.slim_to_native_tuple] = xp.asarray(image.array)
1112+
image_native[image.mask.slim_to_native_tuple] = image.array
11201113

11211114
# add blurring contribution if provided
11221115
if blurring_image is not None:
11231116

1124-
image_native[blurring_image.mask.slim_to_native_tuple] = xp.asarray(
1125-
blurring_image.array
1126-
)
1117+
image_native[blurring_image.mask.slim_to_native_tuple] = blurring_image.array
1118+
11271119
else:
11281120
warnings.warn(
11291121
"No blurring_image provided. Only the direct image will be convolved. "

0 commit comments

Comments
 (0)