Skip to content

Commit

Permalink
Ignore pillow typings
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Oct 19, 2024
1 parent 26e4630 commit b7818c0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import functools
import os
import types
import typing
from typing import TYPE_CHECKING
from unittest import TestCase as _Base

Expand Down Expand Up @@ -113,13 +114,14 @@ def assertNdarraysEqual(a: np.ndarray, b: np.ndarray) -> None:
assert False, f"ndarrays contents differ\n{msg}"


@typing.no_type_check
def assertImagesAlmostEqual(a: Image, b: Image, epsilon: float = 0.1) -> None:
import PIL.ImageFilter as ImageFilter

assert a.size == b.size
a = a.filter(ImageFilter.BLUR).getdata()
b = b.filter(ImageFilter.BLUR).getdata()
for i, ax, bx in zip(range(len(a)), a, b): # type: ignore
for i, ax, bx in zip(range(len(a)), a, b):
diff = sum(abs(ac / 256 - bc / 256) for ac, bc in zip(ax, bx)) / 3
assert diff < epsilon, f"images differed by {diff} at index {i}; {ax} {bx}"

Expand Down

0 comments on commit b7818c0

Please sign in to comment.