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

MRG, MAINT: Clean up VTK9 offset array #7953

Merged
merged 1 commit into from
Jul 1, 2020
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
2 changes: 0 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,6 @@ def reset_warnings(gallery_conf, fname):
'ignore', '.*semaphore_tracker: process died unexpectedly.*')
warnings.filterwarnings( # needed until SciPy 1.2.0 is released
'ignore', '.*will be interpreted as an array index.*', module='scipy')
warnings.filterwarnings( # PyVista needs to be updated (?)
'ignore', '.*VTK 9 no longer accepts an offset array.*')
for key in ('HasTraits', r'numpy\.testing', 'importlib', r'np\.loads',
'Using or importing the ABCs from', # internal modules on 3.7
r"it will be an error for 'np\.bool_'", # ndimage
Expand Down
1 change: 0 additions & 1 deletion mne/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def pytest_configure(config):
ignore:.*sphinx\.util\.smartypants is deprecated.*:
ignore:.*pandas\.util\.testing is deprecated.*:
ignore:.*tostring.*is deprecated.*:DeprecationWarning
ignore:VTK 9 no longer accepts an offset array:UserWarning
always:.*get_data.* is deprecated in favor of.*:DeprecationWarning
""" # noqa: E501
for warning_line in warning_lines.split('\n'):
Expand Down
8 changes: 6 additions & 2 deletions mne/viz/backends/_pyvista.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# License: Simplified BSD

from contextlib import contextmanager
from distutils.version import LooseVersion
import os
import sys
import warnings
Expand All @@ -33,6 +34,7 @@
from pyvista import BackgroundPlotter
from pyvista.utilities import try_callback
from pyvista.plotting.plotting import _ALL_PLOTTERS
VTK9 = LooseVersion(vtk.VTK_VERSION) >= LooseVersion('9.0')


_FIGURES = dict()
Expand Down Expand Up @@ -373,10 +375,12 @@ def quiver3d(self, x, y, z, u, v, w, color, scale, mode, resolution=8,
vectors = np.c_[u, v, w]
points = np.vstack(np.c_[x, y, z])
n_points = len(points)
offset = np.arange(n_points) * 3
cell_type = np.full(n_points, vtk.VTK_VERTEX)
cells = np.c_[np.full(n_points, 1), range(n_points)]
grid = UnstructuredGrid(offset, cells, cell_type, points)
args = (cells, cell_type, points)
if not VTK9:
args = (np.arange(n_points) * 3,) + args
grid = UnstructuredGrid(*args)
grid.point_arrays['vec'] = vectors
if scale_mode == 'scalar':
grid.point_arrays['mag'] = np.array(scalars)
Expand Down