Skip to content

Commit 119866d

Browse files
committed
fix inversion plotters
1 parent dd7ca45 commit 119866d

5 files changed

Lines changed: 14 additions & 16 deletions

File tree

autoarray/inversion/inversion/imaging/w_tilde.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,14 +521,14 @@ def mapped_reconstructed_data_dict(self) -> Dict[LinearObj, Array2D]:
521521
reconstruction=reconstruction,
522522
)
523523

524+
mapped_reconstructed_image = self.psf.convolve_image_no_blurring(
525+
image=mapped_reconstructed_image, mask=self.mask
526+
).array
527+
524528
mapped_reconstructed_image = Array2D(
525-
values=mapped_reconstructed_image, mask=self.mask
529+
values=np.array(mapped_reconstructed_image), mask=self.mask
526530
)
527531

528-
mapped_reconstructed_image = np.array(self.psf.convolve_image_no_blurring(
529-
image=mapped_reconstructed_image, mask=self.mask
530-
).array)
531-
532532
else:
533533
operated_mapping_matrix = self.linear_func_operated_mapping_matrix_dict[
534534
linear_obj

autoarray/inversion/pixelization/mappers/mapper_grids.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def image_plane_data_grid(self):
7272

7373
@property
7474
def mesh_pixels_per_image_pixels(self):
75+
7576
mesh_pixels_per_image_pixels = grid_2d_util.grid_pixels_in_mask_pixels_from(
7677
grid=np.array(self.image_plane_mesh_grid),
7778
shape_native=self.mask.shape_native,

autoarray/operators/contour.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ def hull(
101101
hull_x = grid_convex[hull_vertices, 0]
102102
hull_y = grid_convex[hull_vertices, 1]
103103

104-
grid_hull = jnp.zeros((len(hull_vertices), 2))
105-
106-
grid_hull[:, 1] = hull_x
107-
grid_hull[:, 0] = hull_y
104+
grid_hull = jnp.stack((hull_y, hull_x), axis=-1)
108105

109106
return grid_hull

autoarray/plot/wrap/two_d/grid_scatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def scatter_grid(self, grid: Union[np.ndarray, Grid2D]):
5555
config_dict["c"] = config_dict["c"][0]
5656

5757
try:
58-
plt.scatter(y=grid[:, 0], x=grid[:, 1], **config_dict)
58+
plt.scatter(y=grid.array[:, 0], x=grid.array[:, 1], **config_dict)
5959
except (IndexError, TypeError):
6060
return self.scatter_grid_list(grid_list=grid)
6161

autoarray/structures/grids/grid_2d_util.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,6 @@ def compute_polygon_area(points):
801801
return 0.5 * np.abs(np.dot(x, np.roll(y, 1)) - np.dot(y, np.roll(x, 1)))
802802

803803

804-
@numba_util.jit()
805804
def grid_pixels_in_mask_pixels_from(
806805
grid, shape_native, pixel_scales, origin
807806
) -> np.ndarray:
@@ -832,10 +831,11 @@ def grid_pixels_in_mask_pixels_from(
832831

833832
mesh_pixels_per_image_pixel = np.zeros(shape=shape_native)
834833

835-
for i in range(grid_pixel_centres.shape[0]):
836-
y = grid_pixel_centres[i, 0]
837-
x = grid_pixel_centres[i, 1]
834+
# Assuming grid_pixel_centres is a 2D array where each row contains (y, x) indices.
835+
y_indices = grid_pixel_centres[:, 0]
836+
x_indices = grid_pixel_centres[:, 1]
838837

839-
mesh_pixels_per_image_pixel[y, x] += 1
838+
# Use np.add.at to increment the specific indices in a safe and efficient manner
839+
np.add.at(mesh_pixels_per_image_pixel, (y_indices, x_indices), 1)
840840

841-
return mesh_pixels_per_image_pixel
841+
return mesh_pixels_per_image_pixel

0 commit comments

Comments
 (0)