Skip to content

Commit

Permalink
feat: remove Image.__array__
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Nov 26, 2024
1 parent e10e6bb commit c20d7b3
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions src/safeds/data/image/containers/_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from safeds.exceptions import IllegalFormatError

if TYPE_CHECKING:
from numpy import dtype, ndarray
from torch import Tensor


Expand Down Expand Up @@ -174,25 +173,6 @@ def __sizeof__(self) -> int:
"""
return sys.getsizeof(self._image_tensor) + self._image_tensor.element_size() * self._image_tensor.nelement()

def __array__(self, numpy_dtype: str | dtype | None = None) -> ndarray:
"""
Return the image as a numpy array.
Returns
-------
numpy_array:
The image as numpy array.
"""
from numpy import uint8

return (
self._image_tensor.permute(1, 2, 0)
.detach()
.cpu()
.numpy()
.astype(uint8 if numpy_dtype is None else numpy_dtype)
)

def _repr_jpeg_(self) -> bytes | None:
"""
Return a JPEG image as bytes.
Expand Down

0 comments on commit c20d7b3

Please sign in to comment.