Skip to content

Commit

Permalink
Tests: require pillow>=9.1.0 & remove backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevdp committed Aug 12, 2022
1 parent 88f2b5e commit f7731c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cloudpickle
colorama>=0.4.4
matplotlib
pillow>=8.3.1
pillow>=9.1.0
pytest-benchmark
pytest-xdist
wheel
16 changes: 4 additions & 12 deletions tests/image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,8 @@

try:
from PIL import Image as PIL_Image
# TODO(jakevdp): remove this try/except when pillow requirement is updated.
try:
# pillow >=9.1.0
PIL_Resampling = PIL_Image.Resampling
except AttributeError:
# pillow <9.1.0
PIL_Resampling = PIL_Image
except ImportError:
PIL_Image = None
PIL_Resampling = None

config.parse_flags_with_absl()

Expand Down Expand Up @@ -114,10 +106,10 @@ def testResizeAgainstPIL(self, dtype, image_shape, target_shape, method):
args_maker = lambda: (rng(image_shape, dtype),)
def pil_fn(x):
pil_methods = {
"nearest": PIL_Resampling.NEAREST,
"bilinear": PIL_Resampling.BILINEAR,
"bicubic": PIL_Resampling.BICUBIC,
"lanczos3": PIL_Resampling.LANCZOS,
"nearest": PIL_Image.Resampling.NEAREST,
"bilinear": PIL_Image.Resampling.BILINEAR,
"bicubic": PIL_Image.Resampling.BICUBIC,
"lanczos3": PIL_Image.Resampling.LANCZOS,
}
img = PIL_Image.fromarray(x.astype(np.float32))
out = np.asarray(img.resize(target_shape[::-1], pil_methods[method]),
Expand Down

0 comments on commit f7731c8

Please sign in to comment.