mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-16 02:04:45 +03:00
[Test] fix Image.fromarray LA mode test
AppVeyor: ERROR: Failure: ImportError (No module named numpy) inspired from: Tests/test_numpy.py
This commit is contained in:
parent
911bd0f7b2
commit
fbb6cae785
|
@ -2,18 +2,28 @@ from helper import unittest, PillowTestCase
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
import numpy as np
|
try:
|
||||||
|
import site
|
||||||
|
import numpy
|
||||||
|
except ImportError:
|
||||||
|
# Skip via setUp()
|
||||||
|
pass
|
||||||
|
|
||||||
class TestImageFromArrayLA(PillowTestCase):
|
class TestImageFromArrayLA(PillowTestCase):
|
||||||
|
|
||||||
def test_sanity(self):
|
def setUp(self):
|
||||||
ar1 = (np.random.random((40,40,2))*255).astype('uint8')
|
try:
|
||||||
im1 = Image.fromarray(ar1)
|
import site
|
||||||
arr = np.array(im1.getdata(), 'uint8')
|
import numpy
|
||||||
ar2 = arr.reshape(im1.size[1], im1.size[0], arr.shape[1])
|
except ImportError:
|
||||||
im2 = Image.fromarray(ar2)
|
self.skipTest("ImportError")
|
||||||
|
|
||||||
self.assert_image_equal(im1, im2)
|
def test_sanity(self):
|
||||||
|
ar1 = (numpy.random.random((40,40,2))*255).astype('uint8')
|
||||||
|
im1 = Image.fromarray(ar1)
|
||||||
|
arr = numpy.array(im1.getdata(), 'uint8')
|
||||||
|
ar2 = arr.reshape(im1.size[1], im1.size[0], arr.shape[1])
|
||||||
|
self.assertTrue(numpy.array_equal(ar1, ar2))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user