def test_optional_package(): pkg, have_pkg, _ = optional_package('fake_pkg') npt.assert_raises(TripWireError, pkg) assert_false(have_pkg) pkg, have_pkg, _ = optional_package('os') assert_true(isinstance(pkg, ModuleType)) npt.assert_equal(pkg.__name__, 'os') assert_true(have_pkg)
def get_info(verbose=False): """Return dict describing the context of this package. Parameters ------------ pkg_path : str path containing __init__.py for package Returns ---------- context : dict with named parameters of interest """ from fury.optpkg import optional_package from os.path import dirname import sys import numpy import scipy import vtk mpl, have_mpl, _ = optional_package('matplotlib') dipy, have_dipy, _ = optional_package('dipy') info = dict(fury_version=__version__, pkg_path=dirname(__file__), commit_hash=__revision_id__, sys_version=sys.version, sys_executable=sys.executable, sys_platform=sys.platform, numpy_version=numpy.__version__, scipy_version=scipy.__version__, vtk_version=vtk.vtkVersion.GetVTKVersion()) d_mpl = dict(matplotlib_version=mpl.__version__) if have_mpl else {} d_dipy = dict(dipy_version=dipy.__version__) if have_dipy else {} info.update(d_mpl) info.update(d_dipy) if verbose: print('\n'.join(['{0}: {1}'.format(k, v) for k, v in info.items()])) return info
from warnings import warn import json from os.path import join as pjoin import numpy as np import vtk from fury.data import DATA_DIR # Allow import, but disable doctests if we don't have matplotlib from fury.optpkg import optional_package cm, have_matplotlib, _ = optional_package('matplotlib.cm') def colormap_lookup_table(scale_range=(0, 1), hue_range=(0.8, 0), saturation_range=(1, 1), value_range=(0.8, 0.8)): """Lookup table for the colormap. Parameters ---------- scale_range : tuple It can be anything e.g. (0, 1) or (0, 255). Usually it is the mininum and maximum value of your data. Default is (0, 1). hue_range : tuple of floats HSV values (min 0 and max 1). Default is (0.8, 0). saturation_range : tuple of floats HSV values (min 0 and max 1). Default is (1, 1). value_range : tuple of floats HSV value (min 0 and max 1). Default is (0.8, 0.8).
import numpy.testing as npt from scipy.ndimage.measurements import center_of_mass from scipy.signal import convolve from fury import shaders from fury import actor, window, primitive as fp from fury.actor import grid from fury.decorators import skip_osx, skip_win from fury.utils import shallow_copy, rotate from fury.testing import assert_greater, assert_greater_equal from fury.primitive import prim_sphere # Allow import, but disable doctests if we don't have dipy from fury.optpkg import optional_package # dipy, have_dipy, _ = optional_package('dipy') matplotlib, have_matplotlib, _ = optional_package('matplotlib') # if have_dipy: # from dipy.data import get_sphere # from dipy.reconst.shm import sh_to_sf_matrix # from dipy.tracking.streamline import (center_streamlines, # transform_streamlines) # from dipy.align.tests.test_streamlinear import fornix_streamlines # from dipy.reconst.dti import color_fa, fractional_anisotropy if have_matplotlib: import matplotlib.pyplot as plt from fury.convert import matplotlib_figure_to_numpy class Sphere(): vertices = None
import os import numpy as np from fury import actor, window import numpy.testing as npt from fury.tmpdirs import InTemporaryDirectory from fury.decorators import xvfb_it from tempfile import mkstemp # Allow import, but disable doctests if we don't have dipy from fury.optpkg import optional_package dipy, have_dipy, _ = optional_package('dipy') if have_dipy: from dipy.tracking.streamline import (center_streamlines, transform_streamlines) from dipy.align.tests.test_streamlinear import fornix_streamlines from dipy.reconst.dti import color_fa, fractional_anisotropy from dipy.data import get_sphere use_xvfb = os.environ.get('TEST_WITH_XVFB', False) skip_it = use_xvfb == 'skip' @npt.dec.skipif(skip_it) @xvfb_it def test_slicer(): renderer = window.renderer() data = (255 * np.random.rand(50, 50, 50)) affine = np.eye(4)
import pytest import numpy as np import numpy.testing as npt from scipy.ndimage.measurements import center_of_mass from fury import shaders from fury import actor, window from fury.actor import grid from fury.primitive import prim_sphere from fury.utils import shallow_copy, rotate from fury.testing import assert_greater, assert_greater_equal # Allow import, but disable doctests if we don't have dipy from fury.optpkg import optional_package dipy, have_dipy, _ = optional_package('dipy') matplotlib, have_matplotlib, _ = optional_package('matplotlib') if have_dipy: from dipy.data import get_sphere from dipy.tracking.streamline import (center_streamlines, transform_streamlines) from dipy.align.tests.test_streamlinear import fornix_streamlines from dipy.reconst.dti import color_fa, fractional_anisotropy if have_matplotlib: import matplotlib.pyplot as plt from fury.convert import matplotlib_figure_to_numpy def test_slicer(verbose=False):
#!/usr/bin/python3 -u from dipy.tracking.utils import length from fury import actor, window from fury.optpkg import optional_package from nibabel.streamlines.tck import TckFile from nibabel.streamlines.trk import TrkFile from PIL import Image import itertools import json import nibabel as nib import numpy as np import os xvfbwrapper, has_xvfbwrapper, setup_module = optional_package('xvfbwrapper') if has_xvfbwrapper: from xvfbwrapper import Xvfb _VIEW_PARAMS = [{ 'view': 'axial', 'cam_pos': (-5.58, 84.98, 467.47), 'focal_pnt': (-8.92, -16.15, 4.47), 'view_up': (0.00, 1.00, -0.21) }, { 'view': 'sagittal_left', 'cam_pos': (-482.32, 3.58, -6.28), 'focal_pnt': (-8.92, -16.15, 4.47), 'view_up': (0.00, 0.00, 1.00) }, { 'view': 'coronal',
----- this file is copied (with minor modifications) from the Nibabel. https://github.com/nipy/nibabel. See COPYING file distributed along with the Nibabel package for the copyright and license terms. """ import functools import warnings import re from fury import __version__ from fury.optpkg import optional_package # packaging.version.parse is a third-party utility but is used by setuptools # (so probably already installed) and is conformant to the current PEP 440. # But just if it is not the case, we use distutils packaging, have_pkg, _ = optional_package('setuptools.extern.packaging') _LEADING_WHITE = re.compile(r'^(\s*)') class ExpiredDeprecationError(RuntimeError): """Error for expired deprecation. Error raised when a called function or method has passed out of its deprecation period. """ pass