From 1d444b67e90335b860430cba2c2360d09e8eff66 Mon Sep 17 00:00:00 2001 From: Ben Greiner Date: Fri, 30 Aug 2024 19:46:20 +0200 Subject: [PATCH 01/22] 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 556ad0483..b34e30f6c 100644 --- a/tvtk/tests/test_array_handler.py +++ b/tvtk/tests/test_array_handler.py @@ -201,8 +201,7 @@ def test_arr2cell_array(self): 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 @@ def test_arr2cell_array(self): 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 From 294df464044b41a04605fa3def9e4fc5fd6ae176 Mon Sep 17 00:00:00 2001 From: Ben Greiner Date: Fri, 30 Aug 2024 20:17:37 +0200 Subject: [PATCH 02/22] 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 b34e30f6c..96ba65278 100644 --- a/tvtk/tests/test_array_handler.py +++ b/tvtk/tests/test_array_handler.py @@ -160,13 +160,16 @@ def test_array2vtk(self): 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.""" From 423fb10b0f6d17920787291b689a6f0c412e91d0 Mon Sep 17 00:00:00 2001 From: Ben Greiner Date: Fri, 30 Aug 2024 20:25:17 +0200 Subject: [PATCH 03/22] 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 80702b0e0..5278c368b 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 From 7b7f8057d286c5c48413a6e308a063dd9d5f2e22 Mon Sep 17 00:00:00 2001 From: Ben Greiner Date: Fri, 30 Aug 2024 20:39:45 +0200 Subject: [PATCH 04/22] 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 30e2802d2..f50a573fe 100644 --- a/mayavi/tests/test_csv_sniff.py +++ b/mayavi/tests/test_csv_sniff.py @@ -12,7 +12,7 @@ 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 @@ def assertAllClose(self, x, y): 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))) From 17e934442bcf070a479d0787e08123f913c1b24c Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 6 Sep 2024 12:28:18 -0400 Subject: [PATCH 05/22] FIX: configobj --- .github/workflows/run-mayavi-tests.yml | 2 +- .gitignore | 1 + mayavi/tools/data_wizards/loadtxt.py | 2 +- tvtk/code_gen.py | 4 ++-- tvtk/tests/test_array_ext.py | 6 +++++- tvtk/wrapper_gen.py | 14 +++++++------- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/run-mayavi-tests.yml b/.github/workflows/run-mayavi-tests.yml index 8d4553fca..2539e32e7 100644 --- a/.github/workflows/run-mayavi-tests.yml +++ b/.github/workflows/run-mayavi-tests.yml @@ -73,7 +73,7 @@ jobs: run: | set -exo pipefail python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade "${{ matrix.qt-api }}" numpy "${{ matrix.vtk }}" pillow pytest traits traitsui + python -m pip install --upgrade "${{ matrix.qt-api }}" numpy "${{ matrix.vtk }}" pillow pytest traits traitsui configobj - name: Install mayavi and tvtk run: python -um pip install -ve .[app] - name: Test Mayavi package diff --git a/.gitignore b/.gitignore index a57949113..3b903dad4 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ docs/build/ docs/html.zip tvtk/tvtk_classes.zip +tvtk/tvtk_classes/ mayavi/images/m2_about.jpg diff --git a/mayavi/tools/data_wizards/loadtxt.py b/mayavi/tools/data_wizards/loadtxt.py index 5278c368b..b4677dee8 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.complex128): + elif issubclass(typ, np.complexfloating): return complex else: return str diff --git a/tvtk/code_gen.py b/tvtk/code_gen.py index 8ad3ab6a9..264a2e9be 100644 --- a/tvtk/code_gen.py +++ b/tvtk/code_gen.py @@ -1,10 +1,10 @@ """This module generates tvtk (Traited VTK) classes from the VTK-Python API. -This can be evoked for example by: +This can be evoked for example by running from the ``mayavi`` root: ..code-block:: console - $ python -ic "from tvtk.code_gen import main; main()" -szv + $ python -m tvtk.code_gen -szvno $PWD/tvtk On failures you can then for example do ``import pdb; pdb.pm()`` to do post-mortem debugging. diff --git a/tvtk/tests/test_array_ext.py b/tvtk/tests/test_array_ext.py index cbb03c743..4320267e8 100644 --- a/tvtk/tests/test_array_ext.py +++ b/tvtk/tests/test_array_ext.py @@ -5,12 +5,16 @@ # Copyright (c) 2005, Enthought, Inc. # License: BSD Style. +import pytest import unittest import numpy from tvtk.array_handler import ID_TYPE_CODE, set_id_type_array_py -from tvtk.array_ext import set_id_type_array +try: + from tvtk.array_ext import set_id_type_array +except ModuleNotFoundError: # not compiled + pytest.skip("array_ext not found", allow_module_level=True) class TestArrayExt(unittest.TestCase): diff --git a/tvtk/wrapper_gen.py b/tvtk/wrapper_gen.py index 95b9810ed..1cf9f8b28 100644 --- a/tvtk/wrapper_gen.py +++ b/tvtk/wrapper_gen.py @@ -1591,22 +1591,22 @@ def _write_trait_with_range(self, klass, out, vtk_attr_name): # the code for this trait, # i.e. getattr(self, name_of_method)(...) special_traits = { - '[a-zA-Z0-9]+\.Output$': ( + r'[a-zA-Z0-9]+\.Output$': ( False, False, '_write_any_output'), - '[a-zA-Z0-9]+\.Source$': ( + r'[a-zA-Z0-9]+\.Source$': ( False, False, '_write_any_source'), - '[a-zA-Z0-9]+\.ScalarType$': ( + r'[a-zA-Z0-9]+\.ScalarType$': ( False, False, '_write_any_scalar_type'), # In VTK > 4.5, Set/GetInput have multiple signatures - '[a-zA-Z0-9]+\.Input$': ( + r'[a-zA-Z0-9]+\.Input$': ( False, False, '_write_any_input'), - '[a-zA-Z0-9]+\.InputConnection$': ( + r'[a-zA-Z0-9]+\.InputConnection$': ( False, False, '_write_any_input_connection'), - '[a-zA-Z0-9\.]+FileName$': ( + r'[a-zA-Z0-9\.]+FileName$': ( True, False, '_write_any_something_file_name'), - '[a-zA-Z0-9\.]+FilePrefix$': ( + r'[a-zA-Z0-9\.]+FilePrefix$': ( True, False, '_write_any_something_file_prefix'), 'vtkImageReader2.HeaderSize$': ( True, False, '_write_image_reader2_header_size'), From 0fc20dc93b29eddd5e157a362f6758481ddea3e4 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 6 Sep 2024 13:07:08 -0400 Subject: [PATCH 06/22] FIX: Maybe? --- tvtk/code_gen.py | 3 +++ tvtk/tests/test_array_handler.py | 2 +- tvtk/vtk_parser.py | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tvtk/code_gen.py b/tvtk/code_gen.py index 264a2e9be..03f7fc8f8 100644 --- a/tvtk/code_gen.py +++ b/tvtk/code_gen.py @@ -8,6 +8,9 @@ On failures you can then for example do ``import pdb; pdb.pm()`` to do post-mortem debugging. + +Exceptions to behaviors based on VTK versions and bugs etc. live in ``wrapper_gen.py`` +and ``tvtk_parser.py``. """ # Author: Prabhu Ramachandran # Copyright (c) 2004-2020, Enthought, Inc. diff --git a/tvtk/tests/test_array_handler.py b/tvtk/tests/test_array_handler.py index 96ba65278..6123b8143 100644 --- a/tvtk/tests/test_array_handler.py +++ b/tvtk/tests/test_array_handler.py @@ -163,7 +163,7 @@ def test_array2vtk(self): # 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'] + int_types = ['byte', 'short', 'int', 'intc', 'int_', 'long', 'longlong'] uint_types = ['ubyte', 'ushort', 'uintc', 'uint', 'ulong', 'ulonglong'] float_types = ['single', 'double'] diff --git a/tvtk/vtk_parser.py b/tvtk/vtk_parser.py index 031af8f33..fa9b57da8 100644 --- a/tvtk/vtk_parser.py +++ b/tvtk/vtk_parser.py @@ -14,7 +14,7 @@ # Local imports (these are relative imports for a good reason). from . import class_tree from . import vtk_module as vtk -from .common import is_version_9 +from .common import is_version_9, vtk_minor_version class VTKMethodParser: @@ -727,6 +727,19 @@ def _find_get_set_methods(self, klass, methods): "UseAxisOrigin", "UseOrientedBounds", "UseTextActor3D", ): default = int(bool(default)) + elif ( + ( + klass_name == "vtkAbstractPolygonalHandleRepresentation3D" + or klass_name.endswith(( + "HandleRepresentation", + "HandleRepresentation2D", + "HandleRepresentation3D", + )) + ) + and key == "DisplayPosition" + and vtk_minor_version < 3 + ): + default = (0., 0., 0.) if value: low = getattr(obj, 'Get%sMinValue' % key)() From 7237d288a7775231c0d9eb09d595bbca15a46550 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 6 Sep 2024 13:24:20 -0400 Subject: [PATCH 07/22] FIX: No build isolation, breaks VTK --- .github/workflows/run-mayavi-tests.yml | 2 +- tvtk/vtk_parser.py | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/run-mayavi-tests.yml b/.github/workflows/run-mayavi-tests.yml index 2539e32e7..13007811c 100644 --- a/.github/workflows/run-mayavi-tests.yml +++ b/.github/workflows/run-mayavi-tests.yml @@ -75,7 +75,7 @@ jobs: python -m pip install --upgrade pip setuptools wheel python -m pip install --upgrade "${{ matrix.qt-api }}" numpy "${{ matrix.vtk }}" pillow pytest traits traitsui configobj - name: Install mayavi and tvtk - run: python -um pip install -ve .[app] + run: python -um pip install --no-build-isolation -ve .[app] - name: Test Mayavi package run: pytest -v mayavi - name: Test tvtk package diff --git a/tvtk/vtk_parser.py b/tvtk/vtk_parser.py index fa9b57da8..27b265e6c 100644 --- a/tvtk/vtk_parser.py +++ b/tvtk/vtk_parser.py @@ -727,19 +727,6 @@ def _find_get_set_methods(self, klass, methods): "UseAxisOrigin", "UseOrientedBounds", "UseTextActor3D", ): default = int(bool(default)) - elif ( - ( - klass_name == "vtkAbstractPolygonalHandleRepresentation3D" - or klass_name.endswith(( - "HandleRepresentation", - "HandleRepresentation2D", - "HandleRepresentation3D", - )) - ) - and key == "DisplayPosition" - and vtk_minor_version < 3 - ): - default = (0., 0., 0.) if value: low = getattr(obj, 'Get%sMinValue' % key)() From b1ab51ed124ea46cdd4c42c60a8c0aeff545d002 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 6 Sep 2024 14:59:26 -0400 Subject: [PATCH 08/22] IFX: More info --- .github/workflows/headless-tests.yml | 8 ++++---- .github/workflows/run-mayavi-tests.yml | 6 +++--- tvtk/vtk_parser.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/headless-tests.yml b/.github/workflows/headless-tests.yml index 96c0ca2fd..d980f728c 100644 --- a/.github/workflows/headless-tests.yml +++ b/.github/workflows/headless-tests.yml @@ -31,10 +31,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install numpy "vtk<9.3" pillow pytest traitsui + python -m pip install numpy "vtk<9.3" pillow pytest pytest-timeout traitsui - name: Install mayavi and tvtk - run: python -m pip install -v . + run: python -m pip install --no-build-isolation -v . - name: Test tvtk package - run: pytest -v --pyargs tvtk + run: pytest -v --timeout=10 --pyargs tvtk - name: Test Mayavi package - run: pytest -v --pyargs mayavi + run: pytest -v --timeout=10 --pyargs mayavi diff --git a/.github/workflows/run-mayavi-tests.yml b/.github/workflows/run-mayavi-tests.yml index 13007811c..1cd688eee 100644 --- a/.github/workflows/run-mayavi-tests.yml +++ b/.github/workflows/run-mayavi-tests.yml @@ -73,10 +73,10 @@ jobs: run: | set -exo pipefail python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade "${{ matrix.qt-api }}" numpy "${{ matrix.vtk }}" pillow pytest traits traitsui configobj + python -m pip install --upgrade "${{ matrix.qt-api }}" numpy "${{ matrix.vtk }}" pillow pytest pytest-timeout traits traitsui configobj - name: Install mayavi and tvtk run: python -um pip install --no-build-isolation -ve .[app] - name: Test Mayavi package - run: pytest -v mayavi + run: pytest -v --timeout=10 mayavi - name: Test tvtk package - run: pytest -sv tvtk + run: pytest -sv --timeout=10 tvtk diff --git a/tvtk/vtk_parser.py b/tvtk/vtk_parser.py index 27b265e6c..031af8f33 100644 --- a/tvtk/vtk_parser.py +++ b/tvtk/vtk_parser.py @@ -14,7 +14,7 @@ # Local imports (these are relative imports for a good reason). from . import class_tree from . import vtk_module as vtk -from .common import is_version_9, vtk_minor_version +from .common import is_version_9 class VTKMethodParser: From 667b2c9218570897f2b56e91c4b34e7315d7319d Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 6 Sep 2024 15:03:00 -0400 Subject: [PATCH 09/22] FIX: Lenient --- .github/workflows/run-mayavi-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-mayavi-tests.yml b/.github/workflows/run-mayavi-tests.yml index 1cd688eee..73cd1e524 100644 --- a/.github/workflows/run-mayavi-tests.yml +++ b/.github/workflows/run-mayavi-tests.yml @@ -79,4 +79,4 @@ jobs: - name: Test Mayavi package run: pytest -v --timeout=10 mayavi - name: Test tvtk package - run: pytest -sv --timeout=10 tvtk + run: pytest -sv --timeout=60 tvtk From 9e5a5796cc8b896d50f7ac945bef9519afeb37d6 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 6 Sep 2024 15:07:34 -0400 Subject: [PATCH 10/22] FIX: Time --- .github/workflows/headless-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/headless-tests.yml b/.github/workflows/headless-tests.yml index d980f728c..8ed9362a8 100644 --- a/.github/workflows/headless-tests.yml +++ b/.github/workflows/headless-tests.yml @@ -34,7 +34,7 @@ jobs: python -m pip install numpy "vtk<9.3" pillow pytest pytest-timeout traitsui - name: Install mayavi and tvtk run: python -m pip install --no-build-isolation -v . - - name: Test tvtk package - run: pytest -v --timeout=10 --pyargs tvtk - name: Test Mayavi package run: pytest -v --timeout=10 --pyargs mayavi + - name: Test tvtk package + run: pytest -v --timeout=60 --pyargs tvtk From a6eac998571ffda13715ec022c04bd5240db8d53 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 6 Sep 2024 15:12:13 -0400 Subject: [PATCH 11/22] FIX: Dup --- .github/workflows/headless-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/headless-tests.yml b/.github/workflows/headless-tests.yml index 8ed9362a8..7d4667168 100644 --- a/.github/workflows/headless-tests.yml +++ b/.github/workflows/headless-tests.yml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install numpy "vtk<9.3" pillow pytest pytest-timeout traitsui + python -m pip install numpy "vtk<9.3" pillow pytest pytest-timeout traitsui configobj - name: Install mayavi and tvtk run: python -m pip install --no-build-isolation -v . - name: Test Mayavi package From e2077e5573db4c53b6cdfa3539bd718d6adaddd9 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 12 Sep 2024 14:48:56 -0400 Subject: [PATCH 12/22] FIX: Reqs --- .github/workflows/headless-tests.yml | 2 +- .github/workflows/run-mayavi-tests.yml | 2 +- mayavi/__init__.py | 1 + setup.py | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/headless-tests.yml b/.github/workflows/headless-tests.yml index 7d4667168..8ed9362a8 100644 --- a/.github/workflows/headless-tests.yml +++ b/.github/workflows/headless-tests.yml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install numpy "vtk<9.3" pillow pytest pytest-timeout traitsui configobj + python -m pip install numpy "vtk<9.3" pillow pytest pytest-timeout traitsui - name: Install mayavi and tvtk run: python -m pip install --no-build-isolation -v . - name: Test Mayavi package diff --git a/.github/workflows/run-mayavi-tests.yml b/.github/workflows/run-mayavi-tests.yml index 73cd1e524..7d680e1ce 100644 --- a/.github/workflows/run-mayavi-tests.yml +++ b/.github/workflows/run-mayavi-tests.yml @@ -73,7 +73,7 @@ jobs: run: | set -exo pipefail python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade "${{ matrix.qt-api }}" numpy "${{ matrix.vtk }}" pillow pytest pytest-timeout traits traitsui configobj + python -m pip install --upgrade "${{ matrix.qt-api }}" numpy "${{ matrix.vtk }}" pillow pytest pytest-timeout traits traitsui - name: Install mayavi and tvtk run: python -um pip install --no-build-isolation -ve .[app] - name: Test Mayavi package diff --git a/mayavi/__init__.py b/mayavi/__init__.py index 8e89a722c..e48b65d2f 100644 --- a/mayavi/__init__.py +++ b/mayavi/__init__.py @@ -9,6 +9,7 @@ __requires__ = [ 'apptools', + 'configobj', 'envisage', 'numpy', 'pyface>=6.1.1', diff --git a/setup.py b/setup.py index 2b81501c2..6f978b4c4 100644 --- a/setup.py +++ b/setup.py @@ -130,8 +130,8 @@ def example_files(self): mlab_ref_dir = join(DEFAULT_INPUT_DIR, 'mayavi', 'auto') source_path = join('examples', 'mayavi') - sources = '(\.py)|(\.rst)$' - excluded_dirs = '^\.' + sources = r'(\.py)|(\.rst)$' + excluded_dirs = r'^\.' target_path = mlab_ref_dir target_time = self.latest_modified(target_path, ignore_dirs=excluded_dirs)[0] From b5d215cf161920921638af5b48042e1dba105167 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 13 Sep 2024 12:10:36 -0400 Subject: [PATCH 13/22] FIX: Fix missing --- tvtk/array_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tvtk/array_handler.py b/tvtk/array_handler.py index 6f42b2e89..7e98fcaba 100644 --- a/tvtk/array_handler.py +++ b/tvtk/array_handler.py @@ -185,6 +185,7 @@ def get_vtk_array_type(numeric_array_type): numpy.dtype(numpy.int8): vtkConstants.VTK_CHAR, numpy.dtype(numpy.int16): vtkConstants.VTK_SHORT, numpy.dtype(numpy.int32): vtkConstants.VTK_INT, + numpy.dtype(numpy.int64): vtkConstants.VTK_LONG, numpy.dtype(numpy.uint32): vtkConstants.VTK_UNSIGNED_INT, numpy.dtype(numpy.uint64): vtkConstants.VTK_UNSIGNED_LONG, numpy.dtype(numpy.float32): vtkConstants.VTK_FLOAT, From c06e151ec75d2c7236cd62b39386f20496cb1d47 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 13 Sep 2024 12:23:56 -0400 Subject: [PATCH 14/22] FIX: More --- tvtk/array_handler.py | 5 ++++- tvtk/tests/test_array_handler.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tvtk/array_handler.py b/tvtk/array_handler.py index 7e98fcaba..708b1fd95 100644 --- a/tvtk/array_handler.py +++ b/tvtk/array_handler.py @@ -42,9 +42,11 @@ if VTK_LONG_TYPE_SIZE == 4: LONG_TYPE_CODE = numpy.int32 ULONG_TYPE_CODE = numpy.uint32 + LONG_LONG_TYPE_CODE = numpy.int64 elif VTK_LONG_TYPE_SIZE == 8: LONG_TYPE_CODE = numpy.int64 ULONG_TYPE_CODE = numpy.uint64 + LONG_LONG_TYPE_CODE = None BASE_REFERENCE_COUNT = vtk.vtkObject().GetReferenceCount() @@ -185,7 +187,6 @@ def get_vtk_array_type(numeric_array_type): numpy.dtype(numpy.int8): vtkConstants.VTK_CHAR, numpy.dtype(numpy.int16): vtkConstants.VTK_SHORT, numpy.dtype(numpy.int32): vtkConstants.VTK_INT, - numpy.dtype(numpy.int64): vtkConstants.VTK_LONG, numpy.dtype(numpy.uint32): vtkConstants.VTK_UNSIGNED_INT, numpy.dtype(numpy.uint64): vtkConstants.VTK_UNSIGNED_LONG, numpy.dtype(numpy.float32): vtkConstants.VTK_FLOAT, @@ -198,6 +199,8 @@ def get_vtk_array_type(numeric_array_type): numpy.dtype(ULONG_TYPE_CODE): vtkConstants.VTK_UNSIGNED_LONG, numpy.dtype(LONG_TYPE_CODE): vtkConstants.VTK_LONG, } + if LONG_LONG_TYPE_CODE is not None: + _extra[numpy.dtype(LONG_LONG_TYPE_CODE)] = vtkConstants.VTK_LONG_LONG for t in _extra: if t not in _arr_vtk: _arr_vtk[t] = _extra[t] diff --git a/tvtk/tests/test_array_handler.py b/tvtk/tests/test_array_handler.py index 6123b8143..bc4588dec 100644 --- a/tvtk/tests/test_array_handler.py +++ b/tvtk/tests/test_array_handler.py @@ -29,6 +29,7 @@ def mysum(arr): class TestArrayHandler(unittest.TestCase): def _check_arrays(self, arr, vtk_arr): self.assertEqual(vtk_arr.GetNumberOfTuples(), len(arr)) + msg = f"\n{vtk_arr}" if len(arr.shape) == 2: dim1 = arr.shape[1] self.assertEqual(vtk_arr.GetNumberOfComponents(), dim1) @@ -45,8 +46,7 @@ def _check_arrays(self, arr, vtk_arr): self.assertEqual(chr(int(vtk_arr.GetTuple1(i))), arr[i]) else: for i in range(len(arr)): - self.assertEqual(vtk_arr.GetTuple1(i), arr[i]) - + self.assertEqual(vtk_arr.GetTuple1(i), arr[i], msg=msg) def test_array2vtk(self): """Test Numeric array to VTK array conversion and vice-versa.""" @@ -63,6 +63,7 @@ def test_array2vtk(self): t_z.append(numpy.array([-2147483648, 0, 2147483647], numpy.int32)) t_z.append(numpy.array([ -9223372036854775808, 0, 9223372036854775807], numpy.int64)) + assert t_z[-1][0] == -9223372036854775808 t_z.append(numpy.array([0, 255], numpy.uint8)) t_z.append(numpy.array([0, 65535], numpy.uint16)) t_z.append(numpy.array([0, 4294967295], numpy.uint32)) From 3584c2c0af78e3c511245aebcb192636aaf72638 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 13 Sep 2024 12:25:30 -0400 Subject: [PATCH 15/22] FIX: More jobs --- .github/workflows/run-mayavi-tests.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-mayavi-tests.yml b/.github/workflows/run-mayavi-tests.yml index 7d680e1ce..7347063eb 100644 --- a/.github/workflows/run-mayavi-tests.yml +++ b/.github/workflows/run-mayavi-tests.yml @@ -23,10 +23,6 @@ jobs: qt-api: 'pyqt6' os: macos-14 # arm64 vtk: 'vtk>=9.3' - - python-version: '3.12' - qt-api: 'pyqt6' - os: windows-latest - vtk: 'vtk>=9.3' - python-version: '3.11' qt-api: 'pyqt6' os: ubuntu-latest @@ -43,6 +39,17 @@ jobs: qt-api: 'pyside6' os: macos-13 vtk: 'vtk<9.3' + # A couple of old NumPys + - python-version: '3.12' + qt-api: 'pyside6' + os: ubuntu-latest + vtk: 'vtk>=9.3' + numpy: 'numpy==1.26.4' + - python-version: '3.12' + qt-api: 'pyside6' + os: windows-latest + vtk: 'vtk>=9.3' + numpy: 'numpy==1.26.4' fail-fast: false defaults: run: @@ -73,7 +80,7 @@ jobs: run: | set -exo pipefail python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade "${{ matrix.qt-api }}" numpy "${{ matrix.vtk }}" pillow pytest pytest-timeout traits traitsui + python -m pip install --upgrade "${{ matrix.qt-api }}" ${{ matrix.numpy || 'numpy' }} "${{ matrix.vtk }}" pillow pytest pytest-timeout traits traitsui - name: Install mayavi and tvtk run: python -um pip install --no-build-isolation -ve .[app] - name: Test Mayavi package From e5945b51909096e3c597ba5243dad98abe9d5087 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 13 Sep 2024 12:27:33 -0400 Subject: [PATCH 16/22] FIX: Qute --- .github/workflows/run-mayavi-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-mayavi-tests.yml b/.github/workflows/run-mayavi-tests.yml index 7347063eb..3f7b51608 100644 --- a/.github/workflows/run-mayavi-tests.yml +++ b/.github/workflows/run-mayavi-tests.yml @@ -80,7 +80,7 @@ jobs: run: | set -exo pipefail python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade "${{ matrix.qt-api }}" ${{ matrix.numpy || 'numpy' }} "${{ matrix.vtk }}" pillow pytest pytest-timeout traits traitsui + python -m pip install --upgrade "${{ matrix.qt-api }}" "${{ matrix.numpy || 'numpy' }}" "${{ matrix.vtk }}" pillow pytest pytest-timeout traits traitsui - name: Install mayavi and tvtk run: python -um pip install --no-build-isolation -ve .[app] - name: Test Mayavi package From 9ed4422bafd26c6a7fe9c21ee72079063e071f0d Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 13 Sep 2024 12:33:38 -0400 Subject: [PATCH 17/22] FIX: Check --- .github/workflows/run-mayavi-tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/run-mayavi-tests.yml b/.github/workflows/run-mayavi-tests.yml index 3f7b51608..a4602e3b1 100644 --- a/.github/workflows/run-mayavi-tests.yml +++ b/.github/workflows/run-mayavi-tests.yml @@ -23,6 +23,10 @@ jobs: qt-api: 'pyqt6' os: macos-14 # arm64 vtk: 'vtk>=9.3' + - python-version: '3.12' + qt-api: 'pyqt6' + os: windows-latest + vtk: 'vtk>=9.3' - python-version: '3.11' qt-api: 'pyqt6' os: ubuntu-latest From fb9bb5c89e611e8227578c67d35025bc30c745d6 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 13 Sep 2024 12:38:22 -0400 Subject: [PATCH 18/22] FIX: Better --- tvtk/array_handler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tvtk/array_handler.py b/tvtk/array_handler.py index 708b1fd95..0aa3aabdf 100644 --- a/tvtk/array_handler.py +++ b/tvtk/array_handler.py @@ -46,7 +46,10 @@ elif VTK_LONG_TYPE_SIZE == 8: LONG_TYPE_CODE = numpy.int64 ULONG_TYPE_CODE = numpy.uint64 - LONG_LONG_TYPE_CODE = None + if VTK_ID_TYPE_SIZE == 4: + LONG_LONG_TYPE_CODE = numpy.int64 + else: + LONG_LONG_TYPE_CODE = None BASE_REFERENCE_COUNT = vtk.vtkObject().GetReferenceCount() From 7c924cf5cde8c3460eb727ace89b7be1fd18de74 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 13 Sep 2024 14:40:50 -0400 Subject: [PATCH 19/22] FIX: Maybe --- mayavi/__init__.py | 1 + mayavi/preferences/preference_manager.py | 10 ++++------ mayavi/tests/test_mlab_source.py | 2 +- setup.cfg | 2 ++ tvtk/array_handler.py | 11 ++--------- tvtk/wrapper_gen.py | 4 ++++ 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/mayavi/__init__.py b/mayavi/__init__.py index e48b65d2f..27c028128 100644 --- a/mayavi/__init__.py +++ b/mayavi/__init__.py @@ -17,6 +17,7 @@ 'traits>=6.0.0', 'traitsui>=7.0.0', 'packaging', + 'importlib_resources; python_version<"3.11"', 'vtk' ] diff --git a/mayavi/preferences/preference_manager.py b/mayavi/preferences/preference_manager.py index efe68ef9e..bf27a046d 100644 --- a/mayavi/preferences/preference_manager.py +++ b/mayavi/preferences/preference_manager.py @@ -21,7 +21,7 @@ # Standard library imports from os.path import join -import pkg_resources +import importlib.resources # Enthought library imports. from traits.etsconfig.api import ETSConfig @@ -106,12 +106,11 @@ def _load_preferences(self): for pkg in ('mayavi.preferences', 'tvtk.plugins.scene'): pref = 'preferences.ini' - pref_file = pkg_resources.resource_stream(pkg, pref) - + pref_file = importlib.resources.files(pkg).joinpath(pref) preferences = self.preferences default = preferences.node('default/') - default.load(pref_file) - pref_file.close() + with open(pref_file, 'rb') as fid: + default.load(fid) finally: # Set back the application home. ETSConfig.application_home = app_home @@ -126,4 +125,3 @@ def _preferences_changed(self, preferences): # A Global preference manager that all other modules can use. preference_manager = PreferenceManager() - diff --git a/mayavi/tests/test_mlab_source.py b/mayavi/tests/test_mlab_source.py index 49c6e87c2..ca574e1dd 100644 --- a/mayavi/tests/test_mlab_source.py +++ b/mayavi/tests/test_mlab_source.py @@ -171,7 +171,7 @@ def test_set(self): self.check_traits() self.check_dataset() - def test_strange_shape(self): + def test_basic_strange_shape(self): " Test the MGlyphSource with strange shapes for the arguments " x, y, z, v, s, src = self.get_data() x = y = z = v = s = 0 diff --git a/setup.cfg b/setup.cfg index 212a94acb..699717f82 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,5 +4,7 @@ addopts = filterwarnings = # Currently unsatisfiable ignore:Workbench will be moved from pyface:PendingDeprecationWarning + # Should be fixed in traits + ignore: module 'sre_.+' is deprecated:DeprecationWarning # We call deprecated methods and classes in our tests, and there are many variants for how the parentheticals are formatted ignore:Call to deprecated .*. \((This|Use|Please|Deprecated|Deprecating|Removed|Part|no|renamed) .*\) -- Deprecated since version.*:DeprecationWarning diff --git a/tvtk/array_handler.py b/tvtk/array_handler.py index 0aa3aabdf..1e1a1db68 100644 --- a/tvtk/array_handler.py +++ b/tvtk/array_handler.py @@ -42,14 +42,9 @@ if VTK_LONG_TYPE_SIZE == 4: LONG_TYPE_CODE = numpy.int32 ULONG_TYPE_CODE = numpy.uint32 - LONG_LONG_TYPE_CODE = numpy.int64 elif VTK_LONG_TYPE_SIZE == 8: LONG_TYPE_CODE = numpy.int64 ULONG_TYPE_CODE = numpy.uint64 - if VTK_ID_TYPE_SIZE == 4: - LONG_LONG_TYPE_CODE = numpy.int64 - else: - LONG_LONG_TYPE_CODE = None BASE_REFERENCE_COUNT = vtk.vtkObject().GetReferenceCount() @@ -202,11 +197,9 @@ def get_vtk_array_type(numeric_array_type): numpy.dtype(ULONG_TYPE_CODE): vtkConstants.VTK_UNSIGNED_LONG, numpy.dtype(LONG_TYPE_CODE): vtkConstants.VTK_LONG, } - if LONG_LONG_TYPE_CODE is not None: - _extra[numpy.dtype(LONG_LONG_TYPE_CODE)] = vtkConstants.VTK_LONG_LONG - for t in _extra: + for t, val in _extra.items(): if t not in _arr_vtk: - _arr_vtk[t] = _extra[t] + _arr_vtk[t] = val try: return _arr_vtk[numeric_array_type] diff --git a/tvtk/wrapper_gen.py b/tvtk/wrapper_gen.py index 1cf9f8b28..7b3afe02f 100644 --- a/tvtk/wrapper_gen.py +++ b/tvtk/wrapper_gen.py @@ -679,6 +679,10 @@ def _gen_state_methods(self, klass, out): if not vtk_val: default = self._reform_name(meths[m][0][0]) + # Weirdness on NumPy 2.1 and vtk >= 9.3 that this does not show up as + # an option and creates problems + if klass.__name__ == "vtkPoints" and m == "DataType" and sys.platform == "win32": + d["int32"] = vtk.VTK_ID_TYPE if extra_val is None: t_def = """tvtk_base.RevPrefixMap(%(d)s, default_value='%(default)s')""" % locals() elif hasattr(extra_val, '__iter__'): From ea2915c9deff105beb65717180ab4c062280a3ac Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 13 Sep 2024 14:45:55 -0400 Subject: [PATCH 20/22] FIX: One moer --- .github/workflows/run-mayavi-tests.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-mayavi-tests.yml b/.github/workflows/run-mayavi-tests.yml index a4602e3b1..bce235ee4 100644 --- a/.github/workflows/run-mayavi-tests.yml +++ b/.github/workflows/run-mayavi-tests.yml @@ -49,6 +49,11 @@ jobs: os: ubuntu-latest vtk: 'vtk>=9.3' numpy: 'numpy==1.26.4' + - python-version: '3.12' + qt-api: 'pyside6' + os: windows-latest + vtk: 'vtk>=9.3' + numpy: 'numpy==2.0.2' - python-version: '3.12' qt-api: 'pyside6' os: windows-latest @@ -84,7 +89,7 @@ jobs: run: | set -exo pipefail python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade "${{ matrix.qt-api }}" "${{ matrix.numpy || 'numpy' }}" "${{ matrix.vtk }}" pillow pytest pytest-timeout traits traitsui + python -m pip install --upgrade "${{ matrix.qt-api }}" "${{ matrix.numpy || 'numpy' }}" "${{ matrix.vtk }}" pillow pytest pytest-timeout traits traitsui --only-binary="numpy,vtk" - name: Install mayavi and tvtk run: python -um pip install --no-build-isolation -ve .[app] - name: Test Mayavi package From 48e9fefab52d51ac73b4df03709e9d8eaf8d5256 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 13 Sep 2024 14:46:08 -0400 Subject: [PATCH 21/22] FIX: Bash --- .github/workflows/run-mayavi-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/run-mayavi-tests.yml b/.github/workflows/run-mayavi-tests.yml index bce235ee4..599bd7d04 100644 --- a/.github/workflows/run-mayavi-tests.yml +++ b/.github/workflows/run-mayavi-tests.yml @@ -85,7 +85,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install dependencies - shell: bash run: | set -exo pipefail python -m pip install --upgrade pip setuptools wheel From e83f4da8e55538a854ec51c879f67b025fca76e7 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 13 Sep 2024 14:46:46 -0400 Subject: [PATCH 22/22] STY: Comment --- .github/workflows/run-mayavi-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-mayavi-tests.yml b/.github/workflows/run-mayavi-tests.yml index 599bd7d04..587adc46f 100644 --- a/.github/workflows/run-mayavi-tests.yml +++ b/.github/workflows/run-mayavi-tests.yml @@ -43,7 +43,7 @@ jobs: qt-api: 'pyside6' os: macos-13 vtk: 'vtk<9.3' - # A couple of old NumPys + # Some old NumPys - python-version: '3.12' qt-api: 'pyside6' os: ubuntu-latest