File mayavi-pr1315-np2tests.patch of Package mayavi

From 1d444b67e90335b860430cba2c2360d09e8eff66 Mon Sep 17 00:00:00 2001
From: Ben Greiner <code@bnavigator.de>
Date: Fri, 30 Aug 2024 19:46:20 +0200
Subject: [PATCH 1/4] simplify assert all true

---
 tvtk/tests/test_array_handler.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tvtk/tests/test_array_handler.py b/tvtk/tests/test_array_handler.py
index 556ad048..b34e30f6 100644
--- a/tvtk/tests/test_array_handler.py
+++ b/tvtk/tests/test_array_handler.py
@@ -201,8 +201,7 @@ class TestArrayHandler(unittest.TestCase):
         cells = array_handler.array2vtkCellArray(a)
         arr = array_handler.vtk2array(cells.GetData())
         expect = numpy.array([3, 0, 1, 2]*3, int)
-        self.assertEqual(numpy.alltrue(numpy.equal(arr, expect)),
-                         True)
+        self.assertTrue(numpy.all(numpy.equal(arr, expect)))
         self.assertEqual(cells.GetNumberOfCells(), N)
 
         # Test if a list of Numeric arrays of different cell lengths works.
@@ -210,8 +209,7 @@ class TestArrayHandler(unittest.TestCase):
         cells = array_handler.array2vtkCellArray(l_a)
         arr = array_handler.vtk2array(cells.GetData())
         expect = numpy.array([1, 0]*3 + [3, 0, 1, 2]*3 + [2, 0,1]*2, int)
-        self.assertEqual(numpy.alltrue(numpy.equal(arr, expect)),
-                         True)
+        self.assertTrue(numpy.all(numpy.equal(arr, expect)))
         self.assertEqual(cells.GetNumberOfCells(), N*2 + 2)
 
         # This should not take a long while.  This merely tests if a
-- 
2.46.0

From 3e6036e7839b00ba3e4de994bb90c89a4f1bcfd1 Mon Sep 17 00:00:00 2001
From: Ben Greiner <code@bnavigator.de>
Date: Fri, 30 Aug 2024 20:17:37 +0200
Subject: [PATCH 2/4] remove numpy.sctypes

---
 tvtk/tests/test_array_handler.py | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/tvtk/tests/test_array_handler.py b/tvtk/tests/test_array_handler.py
index b34e30f6..92975880 100644
--- a/tvtk/tests/test_array_handler.py
+++ b/tvtk/tests/test_array_handler.py
@@ -160,13 +160,16 @@ class TestArrayHandler(unittest.TestCase):
         self.assertEqual(vtk_arr.GetValue(2), 0)
         self.assertEqual(vtk_arr.GetValue(3), 1)
 
-        # Make sure the code at least runs for all the non-complex
-        # numerical dtypes in numpy.
-        float_types = [x for x in numpy.sctypes['float']
-                       if x().dtype.name not in ('float16', 'float128')]
-        for dtype in (numpy.sctypes['int'] + numpy.sctypes['uint'] +
-                      float_types):
-            array_handler.array2vtk(numpy.zeros((1,), dtype=dtype))
+        # Make sure the code at least runs for all 
+        # numerical dtypes in numpy
+        # except for half, longdouble and complexfloating
+        int_types = ['byte', 'short', 'intc', 'int_', 'long', 'longlong']
+        uint_types = ['ubyte', 'ushort', 'uintc', 'uint', 'ulong',
+                      'ulonglong']
+        float_types = ['single', 'double']       
+        for dtype in int_types + uint_types + float_types:
+            array_handler.array2vtk(numpy.zeros((1,),
+                                    dtype=numpy.dtype(dtype)))
 
     def test_arr2cell_array(self):
         """Test Numeric array to vtkCellArray conversion."""
-- 
2.46.0

From ddf9be4e816dcaaa599f4b8d90e24199b377f9f9 Mon Sep 17 00:00:00 2001
From: Ben Greiner <code@bnavigator.de>
Date: Fri, 30 Aug 2024 20:25:17 +0200
Subject: [PATCH 3/4] replace complex_

---
 mayavi/tools/data_wizards/loadtxt.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mayavi/tools/data_wizards/loadtxt.py b/mayavi/tools/data_wizards/loadtxt.py
index 80702b0e..5278c368 100644
--- a/mayavi/tools/data_wizards/loadtxt.py
+++ b/mayavi/tools/data_wizards/loadtxt.py
@@ -23,7 +23,7 @@ def _getconv(dtype):
         return lambda x: int(float(x))
     elif issubclass(typ, np.floating):
         return float
-    elif issubclass(typ, np.complex_):
+    elif issubclass(typ, np.complex128):
         return complex
     else:
         return str
-- 
2.46.0

From 668cbfbaac8e380b603501ebe0b7f90bbbb9551b Mon Sep 17 00:00:00 2001
From: Ben Greiner <code@bnavigator.de>
Date: Fri, 30 Aug 2024 20:39:45 +0200
Subject: [PATCH 4/4] handle new numpy2 nan repr

---
 mayavi/tests/test_csv_sniff.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mayavi/tests/test_csv_sniff.py b/mayavi/tests/test_csv_sniff.py
index 30e2802d..f50a573f 100644
--- a/mayavi/tests/test_csv_sniff.py
+++ b/mayavi/tests/test_csv_sniff.py
@@ -12,7 +12,7 @@ import unittest
 import tempfile
 from unittest import SkipTest
 
-from numpy import array, ndarray
+from numpy import array, ndarray, isnan
 
 from mayavi.tools.data_wizards.csv_sniff import \
      Sniff, loadtxt, loadtxt_unknown, array2dict
@@ -33,8 +33,8 @@ class Util(unittest.TestCase):
 
     def assertClose(self, a, b):
         if isinstance(a, (int, float)):
-            if repr(a) == 'nan':
-                self.assertTrue(repr(b) == 'nan')
+            if isnan(a):
+                self.assertTrue(isnan(b), '%r != %r' % (a ,b))
             else:
                 self.assertTrue(abs(a - b) < 1e-6 * max(1, abs(a)),
                              '%r != %r  %r' % (a, b, abs(a - b)))
-- 
2.46.0

openSUSE Build Service is sponsored by