Skip to content

Commit 80b6059

Browse files
committed
add more test cases
1 parent 3036094 commit 80b6059

File tree

139 files changed

+160
-51
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+160
-51
lines changed

blendmodes/imgdiff.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from __future__ import annotations
2+
13
import numpy as np
24
from PIL import Image
35

46

5-
67
def is_x_diff(
78
img1in: Image.Image,
89
img2in: Image.Image,
@@ -53,14 +54,15 @@ def is_x_diff(
5354
compare_res = image_diff(img1in, img2in, compare_mode, percentage=percentage)
5455
return cmp_diff - tolerance <= compare_res <= cmp_diff + tolerance
5556

57+
5658
def is_equal(
5759
img1in: Image.Image,
5860
img2in: Image.Image,
5961
compare_mode: str = "RGBA",
6062
tolerance: float = 0,
6163
*,
6264
percentage: bool = True,
63-
):
65+
) -> bool:
6466
"""
6567
Compare two images and return True/False if the image is within `tolerance` of
6668
`cmp_diff`.
@@ -144,9 +146,7 @@ def image_diff(
144146
return image_diff_array(img1, img2) * (100 if percentage else 1)
145147

146148

147-
def image_diff_array(
148-
img1in: Image.Image | np.ndarray, img2in: Image.Image | np.ndarray
149-
) -> float:
149+
def image_diff_array(img1in: Image.Image | np.ndarray, img2in: Image.Image | np.ndarray) -> float:
150150
"""
151151
Compare two images and return difference between 0, and 1.
152152
Supports both PIL Images and NumPy arrays.
@@ -191,5 +191,6 @@ def image_diff_array(
191191

192192
if __name__ == "__main__":
193193
import doctest
194+
194195
doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE)
195196
doctest.testmod()

documentation/reference/blendmodes/imgdiff.md

Lines changed: 5 additions & 5 deletions

documentation/tutorials/README.md

Lines changed: 35 additions & 32 deletions

documentation/tutorials/blend_examples.md

tests/data/additive_expected.png

-24.8 KB
Binary file not shown.
27.8 KB
21.9 KB
15.6 KB
16.5 KB
10.5 KB

0 commit comments

Comments
 (0)