Skip to content

Commit

Permalink
BUG: Invoke the right image type
Browse files Browse the repository at this point in the history
  • Loading branch information
jwboth committed Jun 25, 2024
1 parent 0ca0d61 commit 5dc6c87
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/darsia/utils/standard_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ def zeros_like(
if dtype is None:
dtype = image.dtype
if mode == "shape":
return darsia.Image(np.zeros(image.shape, dtype=dtype), metadata=image.metadata)
ImageType = type(image)
return ImageType(np.zeros(image.shape, dtype=dtype), metadata=image.metadata)
elif mode == "voxels":
return darsia.Image(
return darsia.ScalarImage(
np.zeros(image.num_voxels, dtype=dtype), metadata=image.metadata
)

Expand All @@ -56,8 +57,9 @@ def ones_like(
if dtype is None:
dtype = image.dtype
if mode == "shape":
return darsia.Image(np.ones(image.shape, dtype=dtype), metadata=image.metadata)
ImageType = type(image)
return ImageType(np.ones(image.shape, dtype=dtype), metadata=image.metadata)
elif mode == "voxels":
return darsia.Image(
return darsia.ScalarImage(
np.ones(image.num_voxels, dtype=dtype), metadata=image.metadata
)

0 comments on commit 5dc6c87

Please sign in to comment.