Skip to content

Commit

Permalink
MAINT: Only apply data conversion if needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwboth committed Jun 18, 2024
1 parent 6962ccc commit eed5d21
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/darsia/corrections/shape/curvature.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,13 @@ def _transform_image(
im_array_as_vector = map_coordinates(
in_data, grid, order=self.interpolation_order
)
# Convert to correct shape and data type
corrected_img[:, :, i] = im_array_as_vector.reshape(shape).astype(img.dtype)
# Convert to correct shape and data type (if necessary)
if im_array_as_vector.dtype == img.dtype:
corrected_img[:, :, i] = im_array_as_vector.reshape(shape)
else:
corrected_img[:, :, i] = im_array_as_vector.reshape(shape).astype(
img.dtype
)

return np.squeeze(corrected_img)

Expand Down

0 comments on commit eed5d21

Please sign in to comment.