Skip to content

Commit

Permalink
Merge pull request #7927 from python-pillow/imagemath
Browse files Browse the repository at this point in the history
Deprecate eval(), replacing it with lambda_eval() and unsafe_eval()
  • Loading branch information
mergify[bot] authored Apr 1, 2024
2 parents a670597 + f5eeeac commit cac6ffa
Show file tree
Hide file tree
Showing 13 changed files with 900 additions and 248 deletions.
4 changes: 3 additions & 1 deletion Tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ def assert_image_similar(

diff = 0
for ach, bch in zip(a.split(), b.split()):
chdiff = ImageMath.eval("abs(a - b)", a=ach, b=bch).convert("L")
chdiff = ImageMath.lambda_eval(
lambda args: abs(args["a"] - args["b"]), a=ach, b=bch
).convert("L")
diff += sum(i * num for i, num in enumerate(chdiff.histogram()))

ave_diff = diff / (a.size[0] * a.size[1])
Expand Down
4 changes: 3 additions & 1 deletion Tests/test_image_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ def assert_compare_images(

bands = ImageMode.getmode(a.mode).bands
for band, ach, bch in zip(bands, a.split(), b.split()):
ch_diff = ImageMath.eval("convert(abs(a - b), 'L')", a=ach, b=bch)
ch_diff = ImageMath.lambda_eval(
lambda args: args["convert"](abs(args["a"] - args["b"]), "L"), a=ach, b=bch
)
ch_hist = ch_diff.histogram()

average_diff = sum(i * num for i, num in enumerate(ch_hist)) / (
Expand Down
214 changes: 0 additions & 214 deletions Tests/test_imagemath.py

This file was deleted.

Loading

0 comments on commit cac6ffa

Please sign in to comment.