mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
* fix(lib): fix This fixes an issue where the `invert` argument would only work for `uint8` dtypes. Now the `max` value is updated according to the pixel array dtype. Maybe we should add unit tests for that, but haven't found an obvious place to put unit tests. * chore(ci): add basic test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(ci): wrong attr name * Update tests/module/mobject/test_image.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
14 lines
438 B
Python
14 lines
438 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):
|
|
array = (255 * np.random.rand(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)
|