manim/tests/module/mobject/test_image.py
F. Muenkel 733a1fa3d3
[Experimental] Fix image test (#4618)
* Fix test_image.py

* Make test_invert_image use the full range of possible RGB values
2026-04-06 14:32:10 -04:00

15 lines
486 B
Python

import numpy as np
import pytest
from manim import ImageMobject
@pytest.mark.parametrize("dtype", [np.uint8, np.uint16])
def test_invert_image(dtype):
rng = np.random.default_rng()
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
array[:, :, :3] = np.iinfo(dtype).max - array[:, :, :3]
assert np.allclose(array, image.pixel_array)