Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Add NumPy include dir during build #1291

Merged
merged 26 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions .github/workflows/headless-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.10']
python-version: ['3.11']
fail-fast: false

runs-on: ${{ matrix.os }}
Expand All @@ -23,19 +23,15 @@ jobs:
ETS_TOOLKIT: 'null'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install numpy
python -m pip install vtk
python -m pip install pillow
python -m pip install pytest
python -m pip install traitsui==7.2.1
python -m pip install numpy "vtk<9.3" pillow pytest traitsui
- name: Install mayavi and tvtk
run: python -m pip install -v .
- name: Test tvtk package
Expand Down
24 changes: 19 additions & 5 deletions .github/workflows/run-mayavi-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,32 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8']
qt-api: ['pyqt5']
vtk: ['vtk<9.3']
include:
# Should run 3.11 once the traits bug goes away
- python-version: '3.10'
- python-version: '3.12'
qt-api: 'pyqt6'
os: ubuntu-latest
vtk: 'vtk>=9.3'
- python-version: '3.12'
qt-api: 'pyqt6'
os: macos-14 # arm64
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'
os: ubuntu-latest
vtk: 'vtk<9.3'
- python-version: '3.10'
qt-api: 'pyside6'
os: windows-latest
vtk: 'vtk<9.3'
- python-version: '3.10'
qt-api: 'pyside6'
os: macos-latest
vtk: 'vtk<9.3'
fail-fast: false
defaults:
run:
Expand All @@ -42,20 +54,22 @@ jobs:
VTK_PARSER_VERBOSE: 'true'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Linux packages for Qt5/Qt6 support and start Xvfb
uses: pyvista/setup-headless-display-action@main
with:
qt: true
if: startsWith(matrix.os, 'ubuntu')
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
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 vtk pillow pytest traits pyface traitsui
python -m pip install --upgrade "${{ matrix.qt-api }}" numpy "${{ matrix.vtk }}" pillow pytest traits traitsui
- name: Install mayavi and tvtk
run: python -um pip install -ve .[app]
- name: Test Mayavi package
Expand Down
19 changes: 15 additions & 4 deletions mayavi/filters/threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Property, Enum
from traitsui.api import View, Group, Item
from tvtk.api import tvtk
from tvtk.common import vtk_major_version, vtk_minor_version

# Local imports
from mayavi.core.filter import Filter
Expand Down Expand Up @@ -165,13 +166,19 @@ def update_data(self):
######################################################################
def _lower_threshold_changed(self, new_value):
fil = self.threshold_filter
fil.threshold_between(new_value, self.upper_threshold)
if (vtk_major_version, vtk_minor_version) >= (9, 1):
fil.lower_threshold = new_value
else:
fil.threshold_between(new_value, self.upper_threshold)
fil.update()
self.data_changed = True

def _upper_threshold_changed(self, new_value):
fil = self.threshold_filter
fil.threshold_between(self.lower_threshold, new_value)
if (vtk_major_version, vtk_minor_version) >= (9, 1):
fil.upper_threshold = new_value
else:
fil.threshold_between(self.lower_threshold, new_value)
fil.update()
self.data_changed = True

Expand Down Expand Up @@ -270,8 +277,12 @@ def _threshold_filter_changed(self, old, new):
return
fil = new
self.configure_connection(fil, self.inputs[0].outputs[0])
fil.threshold_between(self.lower_threshold,
self.upper_threshold)
if (vtk_major_version, vtk_minor_version) >= (9, 1):
fil.lower_threshold = self.lower_threshold
fil.upper_threshold = self.upper_threshold
else:
fil.threshold_between(self.lower_threshold,
self.upper_threshold)
fil.update()
self._set_outputs([fil])

Expand Down
4 changes: 2 additions & 2 deletions mayavi/tests/test_set_active_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def check(self):
c = src.children[1]
sc = get_output(c.outputs[0]).point_data.scalars
self.assertEqual(sc.name,'temperature')
# It is an iso-contour!
self.assertEqual(sc.range[0],sc.range[1])
# It is an iso-contour! Allow rounding differences
self.assertAlmostEqual(sc.range[0], sc.range[1], places=5)
aa = c.children[0].children[0]
self.assertEqual(aa.point_scalars_name,'pressure')
sc = get_output(aa.outputs[0]).point_data.scalars
Expand Down
4 changes: 2 additions & 2 deletions mayavi/tools/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def figure(figure=None, bgcolor=None, fgcolor=None, engine=None,
engine.new_scene(name=name, size=size)
engine.current_scene.name = name
else:
if type(figure) in (int, np.int0, np.int8,
if type(figure) in (int, np.intp, np.int8,
np.int16, np.int32, np.int64):
name = int(figure)
__scene_number_list.update((name,))
Expand Down Expand Up @@ -165,7 +165,7 @@ def close(scene=None, all=False):
if scene is None:
scene = engine.current_scene
else:
if type(scene) in (int, np.int0, np.int8,
if type(scene) in (int, np.intp, np.int8,
np.int16, np.int32, np.int64):
scene = int(scene)
name = 'Mayavi Scene %d' % scene
Expand Down
9 changes: 4 additions & 5 deletions mayavi/version.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Wrapped in a try/except in those situations where someone hasn't installed
# as an egg. What do we do then? For now, we just punt since we don't want
# to define the version number in two places.
import importlib.metadata

try:
import pkg_resources
version = pkg_resources.require('Mayavi')[0].version
except:
version = importlib.metadata.version("mayavi")
except Exception:
version = ''


Loading