Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Rename typing.Image type aliases to PixelArray to avoid conflict with PIL.Image (#3851)

Francisco Manríquez Novoa67f95db213ab
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py
index 6e405a18e..ee487a7fc 100644
--- a/manim/mobject/mobject.py
+++ b/manim/mobject/mobject.py
@@ -44,11 +44,11 @@ if TYPE_CHECKING:
from manim.typing import (
FunctionOverride,
- Image,
ManimFloat,
ManimInt,
MappingFunction,
PathFuncType,
+ PixelArray,
Point3D,
Point3D_Array,
Vector3D,
@@ -825,7 +825,7 @@ class Mobject:
# Displaying
- def get_image(self, camera=None) -> Image:
+ def get_image(self, camera=None) -> PixelArray:
if camera is None:
from ..camera.camera import Camera
diff --git a/manim/typing.py b/manim/typing.py
index 8111ca739..699bbf3b4 100644
--- a/manim/typing.py
+++ b/manim/typing.py
@@ -77,10 +77,10 @@ __all__ = [
"FunctionOverride",
"PathFuncType",
"MappingFunction",
- "Image",
- "GrayscaleImage",
- "RGBImage",
- "RGBAImage",
+ "PixelArray",
+ "GrayscalePixelArray",
+ "RGBPixelArray",
+ "RGBAPixelArray",
"StrPath",
"StrOrBytesPath",
]
@@ -582,7 +582,7 @@ MappingFunction: TypeAlias = Callable[[Point3D], Point3D]
Image types
"""
-Image: TypeAlias = npt.NDArray[ManimInt]
+PixelArray: TypeAlias = npt.NDArray[ManimInt]
"""``shape: (height, width) | (height, width, 3) | (height, width, 4)``
A rasterized image with a height of ``height`` pixels and a width of
@@ -595,24 +595,24 @@ lightness (for greyscale images), an `RGB_Array_Int` or an
`RGBA_Array_Int`.
"""
-GrayscaleImage: TypeAlias = Image
+GrayscalePixelArray: TypeAlias = PixelArray
"""``shape: (height, width)``
-A 100% opaque grayscale `Image`, where every pixel value is a
+A 100% opaque grayscale `PixelArray`, where every pixel value is a
`ManimInt` indicating its lightness (black -> gray -> white).
"""
-RGBImage: TypeAlias = Image
+RGBPixelArray: TypeAlias = PixelArray
"""``shape: (height, width, 3)``
-A 100% opaque `Image` in color, where every pixel value is an
+A 100% opaque `PixelArray` in color, where every pixel value is an
`RGB_Array_Int` object.
"""
-RGBAImage: TypeAlias = Image
+RGBAPixelArray: TypeAlias = PixelArray
"""``shape: (height, width, 4)``
-An `Image` in color where pixels can be transparent. Every pixel
+A `PixelArray` in color where pixels can be transparent. Every pixel
value is an `RGBA_Array_Int` object.
"""