Skip to content

Commit

Permalink
Merge branch 'enthought:master' into syntaxwarnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c authored Dec 19, 2024
2 parents ba54d03 + d5b9c58 commit 2d0c82b
Show file tree
Hide file tree
Showing 45 changed files with 296 additions and 264 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
actions:
patterns:
- "*"
10 changes: 5 additions & 5 deletions .github/workflows/headless-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
- name: Test tvtk package
run: pytest -v --pyargs tvtk
run: python -m pip install --no-build-isolation -v .
- name: Test Mayavi package
run: pytest -v --pyargs mayavi
run: pytest -v --timeout=10 --pyargs mayavi
- name: Test tvtk package
run: pytest -v --timeout=60 --pyargs tvtk
77 changes: 54 additions & 23 deletions .github/workflows/run-mayavi-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,68 @@ jobs:
tests:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-13]
python-version: ['3.9']
qt-api: ['pyqt5']
vtk: ['vtk<9.3']
# Always test against the latest VTK, NumPy, and Qt bindings
os: [ubuntu-latest, windows-latest, macos-13, macos-15]
python-version: ['3.12']
qt-api: ['pyside6'] # prefer the modern bindings
vtk: ['vtk>=9.4'] # always prefer the latest
# Then add some backward compat checks
include:
- python-version: '3.12'
# PyQt6 and vtk 9.3
- python-version: '3.10'
qt-api: 'pyqt6'
os: ubuntu-latest
vtk: 'vtk>=9.3'
- python-version: '3.12'
vtk: 'vtk==9.3'
- python-version: '3.10'
qt-api: 'pyqt6'
os: macos-14 # arm64
vtk: 'vtk>=9.3'
- python-version: '3.12'
vtk: 'vtk==9.3'
- python-version: '3.10'
qt-api: 'pyqt6'
os: windows-latest
vtk: 'vtk>=9.3'
vtk: 'vtk==9.3'
- python-version: '3.11'
qt-api: 'pyqt6'
os: ubuntu-latest
vtk: 'vtk>=9.3'
- python-version: '3.10'
qt-api: 'pyside6'
vtk: 'vtk==9.3'
# PyQt5 and vtk 9.2 (and one oldest Python)
- python-version: '3.9'
qt-api: 'pyqt5'
os: ubuntu-latest
vtk: 'vtk<9.3'
vtk: 'vtk==9.2.5'
- python-version: '3.10'
qt-api: 'pyside6'
qt-api: 'pyqt5'
os: windows-latest
vtk: 'vtk<9.3'
vtk: 'vtk==9.2.5'
- python-version: '3.10'
qt-api: 'pyside6'
os: macos-13
vtk: 'vtk<9.3'
vtk: 'vtk==9.2.5'
# Some 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'
# Older Python and VTKs
- python-version: '3.10'
qt-api: 'pyqt5'
os: ubuntu-latest
vtk: 'vtk==9.2.2'
# TVTK tests intermittently segfault on 9.1
# - python-version: '3.9'
# qt-api: 'pyqt5'
# os: ubuntu-latest
# vtk: 'vtk==9.1.0'
- python-version: '3.9'
qt-api: 'pyqt5'
os: ubuntu-latest
vtk: 'vtk==9.0.2' # oldest available on 3.9 which is the oldest Python we support
fail-fast: false
defaults:
run:
Expand All @@ -56,11 +85,14 @@ jobs:
QT_API: ${{ matrix.qt-api }}
TVTK_VERBOSE: 'true'
VTK_PARSER_VERBOSE: 'true'
PYTHONUNBUFFERED: '1'

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Linux packages for Qt5/Qt6 support and start Xvfb
uses: pyvista/setup-headless-display-action@main
uses: pyvista/setup-headless-display-action@v3
with:
qt: true
if: startsWith(matrix.os, 'ubuntu')
Expand All @@ -69,14 +101,13 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash
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 }}" "${{ 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 -ve .[app]
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=60 tvtk
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ docs/build/

docs/html.zip
tvtk/tvtk_classes.zip
tvtk/tvtk_classes/
mayavi/images/m2_about.jpg
13 changes: 6 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ By itself Mayavi is not a difficult package to install but its dependencies
are unfortunately rather heavy. However, many of these dependencies are now
available as wheels on PyPI. The two critical dependencies are,

1. VTK_
2. A GUI toolkit, either PyQt4_, PySide_, PySide2_, PyQt5_ or wxPython_.
1. VTK_ >= 9.0
2. A GUI toolkit, either PySide6_, PyQt6_, PySide2_, PyQt5_, or wxPython_.

The latest VTK wheels are available on all the major platforms (Windows,
MacOS, and Linux), but only for 64 bit machines. Python 3.x is fully supported
on all these operating systems and Python 2.7.x on MacOS and Linux. If you are
MacOS, and Linux). If you are
out of luck, and your platform is not supported then you will need to install
VTK yourself using your particular distribution as discussed in the `General
Build and Installation instructions
Expand Down Expand Up @@ -133,7 +132,7 @@ If you are unable to do this, read the documentation above and find a way to
install VTK and a suitable UI toolkit and then repeat the above.

If you are interested in the jupyter notebook support as well, do the
following (after ensuring that you have jupyter installed of course.
following (after ensuring that you have jupyter installed of course.
**Note, the Jupyter notebook function is only supported starting mayavi
version 4.5.0**)::

Expand Down Expand Up @@ -200,8 +199,8 @@ Test suite

The basic test suites for tvtk and mayavi can be run using nose::

nosetests -v tvtk/tests
nosetests -v mayavi
pytest -v tvtk/tests
pytest -v mayavi

The integration tests::

Expand Down
2 changes: 1 addition & 1 deletion docs/source/mayavi/application.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ In addition, you can save different layouts into different
Shown below is a specifically configured Mayavi user interface view.
In this view the size of the various parts are changed.

.. image:: images/mayavi_ui_second.jpg
.. image:: images/mayavi_ui_second.png
:alt: Figure of Mayavi's UI after being configured by a user.
:align: center

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This example is discussed in details in the section
:ref:`embedding_mayavi_traits`.


.. image:: ../images/example_mlab_interactive_dialog.jpg
.. image:: ../images/example_mlab_interactive_dialog.png
:align: center


Expand Down
2 changes: 1 addition & 1 deletion docs/source/mayavi/auto/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ applications.
<br/>


.. |0106| image:: ../images/example_mlab_interactive_dialog.jpg
.. |0106| image:: ../images/example_mlab_interactive_dialog.png
:width: 150


Expand Down
2 changes: 1 addition & 1 deletion docs/source/mayavi/building_applications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ In a dialog, this would be::

This code creates the following dialog:

.. image:: images/example_mlab_interactive_dialog.jpg
.. image:: images/example_mlab_interactive_dialog.png
:align: center

A complete, runnable, code based on the above comments is given in the
Expand Down
2 changes: 1 addition & 1 deletion docs/source/mayavi/example_exploring_a_vector_field.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ vector field is still too dense, therefore we go to the `Masking` tab to
enable masking, mask with an `on ratio` of 6 (one arrow out of 6 is
masked) and turn off the random mode.

.. image:: example_vector_cut_plane.jpg
.. image:: example_vector_cut_plane.png
:scale: 50


Expand Down
2 changes: 1 addition & 1 deletion docs/source/mayavi/example_fire.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ As can be seen from the example, it is quite easy to script mayavi to
visualize data. An image of a resulting visualization generated from
this script is shown below.

.. image:: images/streamline.jpg
.. image:: images/streamline.png
:alt: Sample visualization of the ``fire_ug.vtu`` dataset.


2 changes: 1 addition & 1 deletion docs/source/mayavi/example_heart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ if you'd like to.
You should have a visualization that looks something like the one
shown below.

.. image:: images/heart.jpg
.. image:: images/heart.png
:alt: Sample visualization of the ``heart.vtk`` dataset.

The nice thing about mayavi is that although in this case all of the
Expand Down
2 changes: 1 addition & 1 deletion docs/source/mayavi/example_parametric_surface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ source. Note that the positioning of the different surfaces were effected by mo
scene via the 'a' key. For more details on this see the section on
:ref:`interaction-with-the-scene`.

.. image:: images/param.jpg
.. image:: images/param.png
:alt: Sample visualization using parametric surfaces.


Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
18 changes: 8 additions & 10 deletions docs/source/tvtk/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,17 @@ tvtk wrapper object is created. The following illustrates this::
>>> cs = tvtk.ConeSource()
>>> o = cs.output
>>> m = tvtk.PolyDataMapper()
>>> m.input = o
>>> print(hash(o))
1109012188
>>> print(hash(m.input))
1109012188
>>> m.input_connection = cs.output_port
>>> print(id(o))
126526931186080
>>> print(id(m.input))
126526931186080
>>> del o
>>> print(hash(m.input))
1119694156
>>> print(id(m.input))
126526931186080

Thus, after `o` is garbage collected `m.input` no longer refers to the
original tvtk object and a new one is created. This is very similar
to VTK's behaviour. Changing this behaviour is tricky and there are no
plans currently to change this.
original tvtk object the old one is cached and returned.


tvtk and traits
Expand Down
2 changes: 2 additions & 0 deletions mayavi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

__requires__ = [
'apptools',
'configobj',
'envisage',
'numpy',
'pyface>=6.1.1',
'pygments', # This is only needed for the Qt backend but we add it anyway.
'traits>=6.0.0',
'traitsui>=7.0.0',
'packaging',
'importlib_resources; python_version<"3.11"',
'vtk'
]

Expand Down
9 changes: 1 addition & 8 deletions mayavi/components/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,7 @@ def update_data(self):
sends a `data_changed` event.
"""
# Invoke render to update any changes.
from mayavi.modules.outline import Outline
from mayavi.components.glyph import Glyph
#FIXME: A bad hack, but without these checks results in seg fault
input = self.inputs[0]
if isinstance(input, Outline) or isinstance(input, Glyph):
self.mapper.update(0)
else:
self.mapper.update()
self.mapper.update()
self.render()

######################################################################
Expand Down
16 changes: 4 additions & 12 deletions mayavi/components/ui/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

from traitsui.api import (View, Group, Item, InstanceEditor,
DropEditor, Tabbed)
from tvtk.api import tvtk
from tvtk.common import vtk_major_version

# The properties view group.
_prop_base_group = Group(Item(name='representation'),
Expand Down Expand Up @@ -48,16 +46,10 @@
)

# The Texture's view group
if vtk_major_version > 7:
_texture_group = Group(Item(name='interpolate'),
Item(name='color_mode'),
Item(name='repeat'),
show_border=True)
else:
_texture_group = Group(Item(name='interpolate'),
Item(name='map_color_scalars_through_lookup_table'),
Item(name='repeat'),
show_border=True)
_texture_group = Group(Item(name='interpolate'),
Item(name='color_mode'),
Item(name='repeat'),
show_border=True)

# The Actor's view group.
_actor_base_group = Group(Item(name='visibility'))
Expand Down
10 changes: 4 additions & 6 deletions mayavi/preferences/preference_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -126,4 +125,3 @@ def _preferences_changed(self, preferences):
# A Global preference manager that all other modules can use.

preference_manager = PreferenceManager()

3 changes: 0 additions & 3 deletions mayavi/tests/test_builtin_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from numpy import array

# Enthought library imports.
from tvtk.common import vtk_major_version
from mayavi.core.null_engine import NullEngine
from mayavi.sources.builtin_image import BuiltinImage
from mayavi.modules.surface import Surface
Expand Down Expand Up @@ -40,8 +39,6 @@ def setUp(self):
image_data.data_source.radius = array([80., 80., 80.])
image_data.data_source.center = array([150., 150., 0.])
image_data.data_source.whole_extent = array([10, 245, 10, 245, 0, 0])
if vtk_major_version < 8:
image_data.data_source.set_update_extent_to_whole_extent()

self.e = e
self.scene = e.current_scene
Expand Down
Loading

0 comments on commit 2d0c82b

Please sign in to comment.