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

Warn users if they don't have FURY installed #1902

Merged
merged 2 commits into from Jul 17, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions dipy/io/vtk.py
Expand Up @@ -4,9 +4,9 @@
from dipy.utils.optpkg import optional_package

# Allow import, but disable doctests if we don't have fury
fury, have_fury, setup_module = optional_package('fury')
fury, has_fury, setup_module = optional_package('fury')

if have_fury:
if has_fury:
from dipy.viz import utils, vtk


Expand Down
18 changes: 11 additions & 7 deletions dipy/viz/__init__.py
@@ -1,23 +1,27 @@
# Init file for visualization package
from __future__ import division, print_function, absolute_import


from dipy.utils.optpkg import optional_package
# Allow import, but disable doctests if we don't have fury
fury, have_fury, _ = optional_package('fury')
fury, has_fury, _ = optional_package(
'fury',
"You do not have FURY installed. Some visualization functions"
"might not work for you. For installation instructions, please visit: "
"https://fury.gl/")


if have_fury:
if has_fury:
from fury import actor, window, colormap, interactor, ui, utils
from fury.window import vtk
from fury.data import (fetch_viz_icons, read_viz_icons,
DATA_DIR as FURY_DATA_DIR)

# We make the visualization requirements optional imports:
_, has_mpl, _ = optional_package('matplotlib',
"You do not have Matplotlib installed. Some"
" visualization functions might not work for"
" you")
_, has_mpl, _ = optional_package(
'matplotlib',
"You do not have Matplotlib installed. Some visualization functions"
"might not work for you. For installation instructions, please visit: "
"https://matplotlib.org/")

if has_mpl:
from . import projections
4 changes: 2 additions & 2 deletions dipy/viz/app.py
Expand Up @@ -4,9 +4,9 @@
from dipy.io.streamline import save_trk
from dipy.utils.optpkg import optional_package

fury, have_fury, setup_module = optional_package('fury')
fury, has_fury, setup_module = optional_package('fury')

if have_fury:
if has_fury:
from dipy.viz import actor, window, ui
from dipy.viz import vtk
from dipy.viz.panel import slicer_panel, build_label
Expand Down
4 changes: 2 additions & 2 deletions dipy/viz/panel.py
@@ -1,9 +1,9 @@
import numpy as np
from dipy.utils.optpkg import optional_package

fury, have_fury, setup_module = optional_package('fury')
fury, has_fury, setup_module = optional_package('fury')

if have_fury:
if has_fury:
from dipy.viz import actor, ui


Expand Down
6 changes: 3 additions & 3 deletions dipy/viz/tests/test_apps.py
Expand Up @@ -5,15 +5,15 @@
from dipy.testing.decorators import xvfb_it, use_xvfb
from dipy.utils.optpkg import optional_package

fury, have_fury, setup_module = optional_package('fury')
fury, has_fury, setup_module = optional_package('fury')

if have_fury:
if has_fury:
from dipy.viz.app import horizon

skip_it = use_xvfb == 'skip'


@npt.dec.skipif(skip_it or not have_fury)
@npt.dec.skipif(skip_it or not has_fury)
@xvfb_it
def test_horizon():

Expand Down
6 changes: 3 additions & 3 deletions dipy/workflows/tests/test_viz.py
Expand Up @@ -9,17 +9,17 @@
from dipy.io.streamline import save_tractogram


fury, have_fury, setup_module = optional_package('fury')
fury, has_fury, setup_module = optional_package('fury')

if have_fury:
if has_fury:
from dipy.workflows.viz import HorizonFlow
from dipy.viz.app import horizon


skip_it = use_xvfb == 'skip'


@npt.dec.skipif(skip_it or not have_fury)
@npt.dec.skipif(skip_it or not has_fury)
@xvfb_it
def test_horizon_flow():

Expand Down