From cc6aa247e41b25ba43c1fddac0d48ec8b1da771d Mon Sep 17 00:00:00 2001 From: "F. Muenkel" <25496279+fmuenkel@users.noreply.github.com> Date: Sat, 28 Feb 2026 19:14:51 -0400 Subject: [PATCH 1/2] Fix test_image.py --- manim/mobject/types/image_mobject.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manim/mobject/types/image_mobject.py b/manim/mobject/types/image_mobject.py index f03541cd1f..5358f877bd 100644 --- a/manim/mobject/types/image_mobject.py +++ b/manim/mobject/types/image_mobject.py @@ -216,6 +216,10 @@ def get_pixel_array(self) -> PixelArray: """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, From 183191c4397972f290a5cb2c909646e1bc20e604 Mon Sep 17 00:00:00 2001 From: "F. Muenkel" <25496279+fmuenkel@users.noreply.github.com> Date: Sat, 28 Feb 2026 22:30:19 -0400 Subject: [PATCH 2/2] Make test_invert_image use the full range of possible RGB values --- manim/mobject/types/image_mobject.py | 4 ---- tests/module/mobject/test_image.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/manim/mobject/types/image_mobject.py b/manim/mobject/types/image_mobject.py index 5358f877bd..6a462d0265 100644 --- a/manim/mobject/types/image_mobject.py +++ b/manim/mobject/types/image_mobject.py @@ -26,8 +26,6 @@ ) 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 @@ from manim.typing import PixelArray, StrPath - from ...camera.moving_camera import MovingCamera - class AbstractImageMobject(Mobject): """ diff --git a/tests/module/mobject/test_image.py b/tests/module/mobject/test_image.py index ef00eb75b9..584068bd45 100644 --- a/tests/module/mobject/test_image.py +++ b/tests/module/mobject/test_image.py @@ -7,7 +7,7 @@ @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