[Experimental] Fix image test (#4618)

* Fix test_image.py

* Make test_invert_image use the full range of possible RGB values
This commit is contained in:
F. Muenkel 2026-04-06 15:32:10 -03:00 committed by GitHub
commit 733a1fa3d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -26,8 +26,6 @@ from ...utils.color import (
)
from ...utils.images import change_to_rgba_array, get_full_raster_image_path
__all__ = ["ImageMobject", "ImageMobjectFromCamera"]
if TYPE_CHECKING:
from typing import Self
@ -35,8 +33,6 @@ if TYPE_CHECKING:
from manim.typing import PixelArray, StrPath
from ...camera.moving_camera import MovingCamera
class AbstractImageMobject(Mobject):
"""
@ -216,6 +212,10 @@ class ImageMobject(AbstractImageMobject):
"""A simple getter method."""
return self.pixel_array
def init_colors(self) -> None:
"""Override base init_colors to avoid overwriting image pixels during init."""
return None
def set_color( # type: ignore[override]
self,
color: ParsableManimColor = YELLOW_C,

View file

@ -7,7 +7,7 @@ from manim import ImageMobject
@pytest.mark.parametrize("dtype", [np.uint8, np.uint16])
def test_invert_image(dtype):
rng = np.random.default_rng()
array = (255 * rng.random((10, 10, 4))).astype(dtype)
array = (np.iinfo(dtype).max * rng.random((10, 10, 4))).astype(dtype)
image = ImageMobject(array, pixel_array_dtype=dtype, invert=True)
assert image.pixel_array.dtype == dtype