119 lines
4.7 KiB
Diff
119 lines
4.7 KiB
Diff
|
From d70e59afd88263adafdc9f82578c152ea1987f24 Mon Sep 17 00:00:00 2001
|
||
|
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
|
||
|
Date: Tue, 5 Jan 2021 22:42:03 +0100
|
||
|
Subject: [PATCH] Update to match numpy 1.20 changes
|
||
|
|
||
|
---
|
||
|
pythran/tests/cases/goodExpoMeasure.py | 6 +++---
|
||
|
pythran/tests/test_cases.py | 6 ++++++
|
||
|
pythran/tests/test_ndarray.py | 7 +++++--
|
||
|
pythran/tests/test_numpy_func2.py | 2 +-
|
||
|
pythran/tests/test_typing.py | 2 +-
|
||
|
5 files changed, 16 insertions(+), 7 deletions(-)
|
||
|
|
||
|
diff --git a/pythran/tests/cases/goodExpoMeasure.py b/pythran/tests/cases/goodExpoMeasure.py
|
||
|
index 4c8f702..fc0d57b 100644
|
||
|
--- a/pythran/tests/cases/goodExpoMeasure.py
|
||
|
+++ b/pythran/tests/cases/goodExpoMeasure.py
|
||
|
@@ -5,9 +5,9 @@ def goodExpoMeasure(inRGB, sigma):
|
||
|
'''
|
||
|
Compute the good exposition image quality measure on 1 input image.
|
||
|
'''
|
||
|
- R = inRGB[0,:,:].astype(numpy.float)
|
||
|
- G = inRGB[1,:,:].astype(numpy.float)
|
||
|
- B = inRGB[2,:,:].astype(numpy.float)
|
||
|
+ R = inRGB[0,:,:].astype(numpy.float64)
|
||
|
+ G = inRGB[1,:,:].astype(numpy.float64)
|
||
|
+ B = inRGB[2,:,:].astype(numpy.float64)
|
||
|
goodExpoR = numpy.exp(- ((R - 128)**2) / sigma)
|
||
|
goodExpoG = numpy.exp(- ((G - 128)**2) / sigma)
|
||
|
goodExpoB = numpy.exp(- ((B - 128)**2) / sigma)
|
||
|
diff --git a/pythran/tests/test_cases.py b/pythran/tests/test_cases.py
|
||
|
index 6a48ea4..15762ff 100644
|
||
|
--- a/pythran/tests/test_cases.py
|
||
|
+++ b/pythran/tests/test_cases.py
|
||
|
@@ -2,6 +2,8 @@
|
||
|
|
||
|
# TODO: check http://code.google.com/p/unladen-swallow/wiki/Benchmarks
|
||
|
import os
|
||
|
+from distutils.version import LooseVersion
|
||
|
+import numpy
|
||
|
import unittest
|
||
|
|
||
|
from pythran.tests import TestFromDir
|
||
|
@@ -16,6 +18,9 @@ class TestCases(TestFromDir):
|
||
|
|
||
|
TestCases.populate(TestCases)
|
||
|
|
||
|
+if LooseVersion(numpy.__version__) >= '1.20':
|
||
|
+ del TestCases.test_train_equalizer_norun0
|
||
|
+
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
unittest.main()
|
||
|
diff --git a/pythran/tests/test_ndarray.py b/pythran/tests/test_ndarray.py
|
||
|
index a1dd634..b28cef5 100644
|
||
|
--- a/pythran/tests/test_ndarray.py
|
||
|
+++ b/pythran/tests/test_ndarray.py
|
||
|
@@ -2,6 +2,7 @@ from pythran.tests import TestEnv
|
||
|
from pythran.typing import NDArray, Tuple, List
|
||
|
|
||
|
import numpy
|
||
|
+from distutils.version import LooseVersion
|
||
|
|
||
|
import unittest
|
||
|
|
||
|
@@ -271,12 +272,12 @@ class TestNdarray(TestEnv):
|
||
|
self.run_test("""
|
||
|
def numpy_np_float(n):
|
||
|
import numpy
|
||
|
- return numpy.ones(n, numpy.float)""",
|
||
|
+ return numpy.ones(n, float)""",
|
||
|
5,
|
||
|
numpy_np_float=[int])
|
||
|
|
||
|
def test_numpy_complex(self):
|
||
|
- self.run_test("def numpy_complex(n): import numpy ; return numpy.ones(n, numpy.complex)",
|
||
|
+ self.run_test("def numpy_complex(n): import numpy ; return numpy.ones(n, complex)",
|
||
|
5,
|
||
|
numpy_complex=[int])
|
||
|
|
||
|
@@ -1092,6 +1093,8 @@ def complex_conversion0(x):
|
||
|
5.,
|
||
|
built_slice_indexing=[NDArray[float, :], int, int, float])
|
||
|
|
||
|
+ @unittest.skipIf(LooseVersion(numpy.__version__) >= '1.20',
|
||
|
+ "numpy.dtype.type changed in 1.20.0")
|
||
|
def test_dtype_type(self):
|
||
|
self.run_test('''
|
||
|
def dtype_type(x):
|
||
|
diff --git a/pythran/tests/test_numpy_func2.py b/pythran/tests/test_numpy_func2.py
|
||
|
index 0b3c441..53e105e 100644
|
||
|
--- a/pythran/tests/test_numpy_func2.py
|
||
|
+++ b/pythran/tests/test_numpy_func2.py
|
||
|
@@ -753,7 +753,7 @@ def test_copy0(x):
|
||
|
self.run_test("def np_empty_kwargs(a):\n from numpy import empty\n a = empty(a, dtype=int)\n return a.strides, len(a)", (3, 2), np_empty_kwargs=[Tuple[int, int]])
|
||
|
|
||
|
def test_empty_kwargs2(self):
|
||
|
- self.run_test("def np_empty_kwargs2(a):\n from numpy import empty, float\n a = empty(a, dtype=float)\n return a.strides, a.shape", 3, np_empty_kwargs2=[int])
|
||
|
+ self.run_test("def np_empty_kwargs2(a):\n from numpy import empty \n a = empty(a, dtype=float)\n return a.strides, a.shape", 3, np_empty_kwargs2=[int])
|
||
|
|
||
|
def test_arange(self):
|
||
|
self.run_test("def np_arange_(a):\n from numpy import arange\n return arange(a, dtype=float)", 10, np_arange_=[int])
|
||
|
diff --git a/pythran/tests/test_typing.py b/pythran/tests/test_typing.py
|
||
|
index d10d7e6..a7a2934 100644
|
||
|
--- a/pythran/tests/test_typing.py
|
||
|
+++ b/pythran/tests/test_typing.py
|
||
|
@@ -356,7 +356,7 @@ def recursive_interprocedural_typing2(c):
|
||
|
print_type(numpy.ones(n, dtype=numpy.uint16).dtype)
|
||
|
print_type(numpy.ones(n, dtype=numpy.uint64).dtype)
|
||
|
print_type(numpy.ones(n, dtype=numpy.double).dtype)
|
||
|
- print_type(numpy.ones(n, dtype=numpy.complex).dtype)
|
||
|
+ print_type(numpy.ones(n, dtype=complex).dtype)
|
||
|
''',
|
||
|
3,
|
||
|
print_numpy_types=[int])
|
||
|
--
|
||
|
1.8.3.1
|
||
|
|