Skip to content

Commit

Permalink
Merge pull request #2820 from ericpre/skip_test_failing_with_scipy_dev
Browse files Browse the repository at this point in the history
Skip test failing with scipy 1.8.0.dev
  • Loading branch information
jlaehne committed Sep 5, 2021
2 parents 69e8a23 + ae29f8f commit 6700537
Show file tree
Hide file tree
Showing 22 changed files with 62 additions and 79 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
os: [ubuntu, windows, macos]
PYTHON_VERSION: [3.8, 3.9]
PIP_SELECTOR: ['[all, tests]']
DEPENDENCIES_DEV: [false]
include:
# test oldest supported version of main dependencies on python 3.6
- os: ubuntu
Expand All @@ -38,13 +37,6 @@ jobs:
PIP_SELECTOR: '[all, tests, coverage]'
PYTEST_ARGS_COVERAGE: --cov=. --cov-report=xml
LABEL: -coverage
# Run test suite against dependencies development version
- os: ubuntu
PYTHON_VERSION: 3.8
PIP_SELECTOR: '[all, tests]'
LABEL: -dependencies_dev
DEPENDENCIES_DEV: true
DEPENDENCIES: numpy scipy scikit-learn scikit-image
- os: ubuntu
PYTHON_VERSION: 3.7
PIP_SELECTOR: '[all, tests]'
Expand Down Expand Up @@ -76,13 +68,6 @@ jobs:
run: |
pip install ${{ matrix.DEPENDENCIES }}
- name: Install dependencies development version
if: ${{ matrix.DEPENDENCIES_DEV }}
run: |
pip install --upgrade --no-deps --pre \
-i https://pypi.anaconda.org/scipy-wheels-nightly/simple \
${{ matrix.DEPENDENCIES }}
- name: Run test suite
run: |
pytest ${{ env.PYTEST_ARGS }} ${{ matrix.PYTEST_ARGS_COVERAGE }}
Expand Down
16 changes: 8 additions & 8 deletions hyperspy/_components/error_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# along with HyperSpy. If not, see <http://www.gnu.org/licenses/>.

from hyperspy._components.expression import Expression
from distutils.version import LooseVersion
from packaging.version import Version
import sympy


Expand All @@ -27,16 +27,16 @@ class Erf(Expression):
.. math::
f(x) = \frac{A}{2}~\mathrm{erf}\left[\frac{(x - x_0)}{\sqrt{2}
f(x) = \frac{A}{2}~\mathrm{erf}\left[\frac{(x - x_0)}{\sqrt{2}
\sigma}\right]
============== =============
Variable Parameter
Variable Parameter
============== =============
:math:`A` A
:math:`\sigma` sigma
:math:`x_0` origin
:math:`A` A
:math:`\sigma` sigma
:math:`x_0` origin
============== =============
Parameters
Expand All @@ -48,10 +48,10 @@ class Erf(Expression):
origin : float
Position of the zero crossing.
"""

def __init__(self, A=1., sigma=1., origin=0., module=["numpy", "scipy"],
**kwargs):
if LooseVersion(sympy.__version__) < LooseVersion("1.3"):
if Version(sympy.__version__) < Version("1.3"):
raise ImportError("The `ErrorFunction` component requires "
"SymPy >= 1.3")
super(Erf, self).__init__(
Expand Down
4 changes: 2 additions & 2 deletions hyperspy/_components/skew_normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import dask.array as da

from hyperspy._components.expression import Expression
from distutils.version import LooseVersion
from packaging.version import Version
import sympy

sqrt2pi = np.sqrt(2 * np.pi)
Expand Down Expand Up @@ -136,7 +136,7 @@ class SkewNormal(Expression):

def __init__(self, x0=0., A=1., scale=1., shape=0.,
module=['numpy', 'scipy'], **kwargs):
if LooseVersion(sympy.__version__) < LooseVersion("1.3"):
if Version(sympy.__version__) < Version("1.3"):
raise ImportError("The `SkewNormal` component requires "
"SymPy >= 1.3")
# We use `_shape` internally because `shape` is already taken in sympy
Expand Down
4 changes: 2 additions & 2 deletions hyperspy/_components/voigt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from hyperspy._components.expression import Expression
from hyperspy._components.gaussian import _estimate_gaussian_parameters
from distutils.version import LooseVersion
from packaging.version import Version

sqrt2pi = math.sqrt(2 * math.pi)
sigma2fwhm = 2 * math.sqrt(2 * math.log(2))
Expand Down Expand Up @@ -87,7 +87,7 @@ def __init__(self, centre=10., area=1., gamma=0.2, sigma=0.1,
# Not to break scripts once we remove the legacy Voigt
if "legacy" in kwargs:
del kwargs["legacy"]
if LooseVersion(sympy.__version__) < LooseVersion("1.3"):
if Version(sympy.__version__) < Version("1.3"):
raise ImportError("The `Voigt` component requires "
"SymPy >= 1.3")
# We use `_gamma` internally to workaround the use of the `gamma`
Expand Down
5 changes: 2 additions & 3 deletions hyperspy/_signals/lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import dask
from dask.diagnostics import ProgressBar
from itertools import product
from distutils.version import LooseVersion

from packaging.version import Version

from hyperspy.signal import BaseSignal
from hyperspy.defaults_parser import preferences
Expand Down Expand Up @@ -1175,7 +1174,7 @@ def compute_navigator(self, index=None, chunks_number=None,
# Needs to reverse the chunks list to match dask chunking order
signal_chunks = list(signal_chunks)[::-1]
navigation_chunks = ['auto'] * len(self.axes_manager.navigation_shape)
if LooseVersion(dask.__version__) >= LooseVersion("2.30.0"):
if Version(dask.__version__) >= Version("2.30.0"):
kwargs = {'balance':True}
else:
kwargs = {}
Expand Down
4 changes: 2 additions & 2 deletions hyperspy/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from traits.trait_numeric import Array
import sympy
from sympy.utilities.lambdify import lambdify
from distutils.version import LooseVersion
from packaging.version import Version
from pathlib import Path

import hyperspy
Expand Down Expand Up @@ -1207,7 +1207,7 @@ def _load_dictionary(self, dic):

if dic['_id_name'] == self._id_name:
if (self._id_name == "Polynomial" and
LooseVersion(hyperspy.__version__) >= LooseVersion("2.0")):
Version(hyperspy.__version__) >= Version("2.0")):
# in HyperSpy 2.0 the polynomial definition changed
from hyperspy._components.polynomial import convert_to_polynomial
dic = convert_to_polynomial(dic)
Expand Down
4 changes: 2 additions & 2 deletions hyperspy/drawing/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# along with HyperSpy. If not, see <http://www.gnu.org/licenses/>.

import math
from distutils.version import LooseVersion
from packaging.version import Version

import numpy as np
import matplotlib
Expand Down Expand Up @@ -509,7 +509,7 @@ def format_coord(x, y):
sym_log_kwargs = {'linthresh':self.linthresh,
'linscale':self.linscale,
'vmin':vmin, 'vmax':vmax}
if LooseVersion(matplotlib.__version__) >= LooseVersion("3.2"):
if Version(matplotlib.__version__) >= Version("3.2"):
sym_log_kwargs['base'] = 10
norm = SymLogNorm(**sym_log_kwargs)
elif inspect.isclass(norm) and issubclass(norm, Normalize):
Expand Down
4 changes: 2 additions & 2 deletions hyperspy/drawing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import copy
import itertools
from distutils.version import LooseVersion
from packaging.version import Version
import textwrap
import traits.api as t
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -1510,7 +1510,7 @@ def plot_histograms(signal_list,

def picker_kwargs(value, kwargs={}):
# picker is deprecated in favor of pickradius
if LooseVersion(mpl.__version__) >= LooseVersion("3.3.0"):
if Version(mpl.__version__) >= Version("3.3.0"):
kwargs.update({'pickradius': value, 'picker':True})
else:
kwargs['picker'] = value
Expand Down
4 changes: 2 additions & 2 deletions hyperspy/external/progressbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
# You should have received a copy of the GNU General Public License
# along with HyperSpy. If not, see <http://www.gnu.org/licenses/>.

from distutils.version import LooseVersion
from packaging.version import Version
from tqdm import __version__ as tqdm_version

if LooseVersion(tqdm_version) >= LooseVersion("4.36.0"):
if Version(tqdm_version) >= Version("4.36.0"):
# API change for 5.0 https://github.com/tqdm/tqdm/pull/800
from tqdm import tqdm
from tqdm.notebook import tqdm as tqdm_notebook
Expand Down
18 changes: 9 additions & 9 deletions hyperspy/io_plugins/hspy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with HyperSpy. If not, see <http://www.gnu.org/licenses/>.

from distutils.version import LooseVersion
from packaging.version import Version
import warnings
import logging
import datetime
Expand Down Expand Up @@ -94,7 +94,7 @@
not_valid_format = 'The file is not a valid HyperSpy hdf5 file'

current_file_version = None # Format version of the file being read
default_version = LooseVersion(version)
default_version = Version(version)


def get_hspy_format_version(f):
Expand All @@ -112,7 +112,7 @@ def get_hspy_format_version(f):
version = "2.0"
else:
raise IOError(not_valid_format)
return LooseVersion(version)
return Version(version)


def file_reader(filename, backing_store=False,
Expand Down Expand Up @@ -205,7 +205,7 @@ def file_reader(filename, backing_store=False,
def hdfgroup2signaldict(group, lazy=False):
global current_file_version
global default_version
if current_file_version < LooseVersion("1.2"):
if current_file_version < Version("1.2"):
metadata = "mapped_parameters"
original_metadata = "original_parameters"
else:
Expand Down Expand Up @@ -274,7 +274,7 @@ def hdfgroup2signaldict(group, lazy=False):
if '__unnamed__' == exp['metadata']['General']['title']:
exp['metadata']["General"]['title'] = ''

if current_file_version < LooseVersion("1.1"):
if current_file_version < Version("1.1"):
# Load the decomposition results written with the old name,
# mva_results
if 'mva_results' in group.keys():
Expand All @@ -298,7 +298,7 @@ def hdfgroup2signaldict(group, lazy=False):
exp['metadata']['name']
del exp['metadata']['name']

if current_file_version < LooseVersion("1.2"):
if current_file_version < Version("1.2"):
if '_internal_parameters' in exp['metadata']:
exp['metadata']['_HyperSpy'] = \
exp['metadata']['_internal_parameters']
Expand Down Expand Up @@ -384,7 +384,7 @@ def hdfgroup2signaldict(group, lazy=False):
exp["metadata"]["Signal"][key] = exp["metadata"][key]
del exp["metadata"][key]

if current_file_version < LooseVersion("3.0"):
if current_file_version < Version("3.0"):
if "Acquisition_instrument" in exp["metadata"]:
# Move tilt_stage to Stage.tilt_alpha
# Move exposure time to Detector.Camera.exposure_time
Expand Down Expand Up @@ -715,7 +715,7 @@ def write_signal(signal, group, **kwds):
"Writes a hyperspy signal to a hdf5 group"

group.attrs.update(get_object_package_info(signal))
if default_version < LooseVersion("1.2"):
if default_version < Version("1.2"):
metadata = "mapped_parameters"
original_metadata = "original_parameters"
else:
Expand All @@ -735,7 +735,7 @@ def write_signal(signal, group, **kwds):
overwrite_dataset(group, signal.data, 'data',
signal_axes=signal.axes_manager.signal_indices_in_array,
**kwds)
if default_version < LooseVersion("1.2"):
if default_version < Version("1.2"):
metadata_dict["_internal_parameters"] = \
metadata_dict.pop("_HyperSpy")
# Remove chunks from the kwds since it wouldn't have the same rank as the
Expand Down
4 changes: 2 additions & 2 deletions hyperspy/io_plugins/mrcz.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with HyperSpy. If not, see <http://www.gnu.org/licenses/>.

from distutils.version import LooseVersion
from packaging.version import Version
import mrcz as _mrcz
import logging

Expand Down Expand Up @@ -44,7 +44,7 @@

# API changes in mrcz 0.5
def _parse_metadata(metadata):
if LooseVersion(_mrcz.__version__) < LooseVersion("0.5"):
if Version(_mrcz.__version__) < Version("0.5"):
return metadata[0]
else:
return metadata
Expand Down
4 changes: 2 additions & 2 deletions hyperspy/io_plugins/tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import tifffile
import traits.api as t
import numpy as np
from distutils.version import LooseVersion
from packaging.version import Version

from hyperspy.misc import rgb_tools
from hyperspy.misc.date_time_tools import get_date_time_from_metadata
Expand Down Expand Up @@ -169,7 +169,7 @@ def _read_serie(tiff, serie, filename, force_read_resolution=False,
'formats': [dtype] * lastshape})
shape = shape[:-1]

if LooseVersion(tifffile.__version__) >= LooseVersion("2020.2.16"):
if Version(tifffile.__version__) >= Version("2020.2.16"):
op = {tag.name: tag.value for tag in page.tags}
else:
op = {key: tag.value for key, tag in page.tags.items()}
Expand Down
4 changes: 2 additions & 2 deletions hyperspy/learn/svd_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import logging
import warnings
from distutils.version import LooseVersion
from packaging.version import Version

import numpy as np
import scipy
Expand Down Expand Up @@ -151,7 +151,7 @@ def svd_solve(
)
U, S, V = randomized_svd(data, n_components=output_dimension, **kwargs)
elif svd_solver == "arpack":
if LooseVersion(scipy.__version__) < LooseVersion("1.4.0"): # pragma: no cover
if Version(scipy.__version__) < Version("1.4.0"): # pragma: no cover
raise ValueError('`svd_solver="arpack"` requires scipy >= 1.4.0')

if output_dimension >= min(m, n):
Expand Down
16 changes: 8 additions & 8 deletions hyperspy/misc/ipython_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# along with HyperSpy. If not, see <http://www.gnu.org/licenses/>.

import __main__
from distutils.version import LooseVersion
from packaging.version import Version

from time import strftime
from pathlib import Path
Expand All @@ -31,11 +31,11 @@ def get_ipython():
if is_it_running_from_ipython is False:
return None
import IPython
ipy_version = LooseVersion(IPython.__version__)
if ipy_version < LooseVersion("0.11"):
ipy_version = Version(IPython.__version__)
if ipy_version < Version("0.11"):
from IPython import ipapi
ip = ipapi.get()
elif ipy_version < LooseVersion("1.0"):
elif ipy_version < Version("1.0"):
from IPython.core import ipapi
ip = ipapi.get()
else:
Expand Down Expand Up @@ -64,8 +64,8 @@ def turn_logging_on(verbose=1):
if ip is None:
return
import IPython
ipy_version = LooseVersion(IPython.__version__)
if ipy_version < LooseVersion("0.11"):
ipy_version = Version(IPython.__version__)
if ipy_version < Version("0.11"):
if verbose == 1:
print("Logging is not supported by this version of IPython")
return
Expand Down Expand Up @@ -95,8 +95,8 @@ def turn_logging_off():
if ip is None:
return
import IPython
ipy_version = LooseVersion(IPython.__version__)
if ipy_version < LooseVersion("0.11"):
ipy_version = Version(IPython.__version__)
if ipy_version < Version("0.11"):
print("Logging is not supported by this version of IPython")
return
elif ip.logger.log_active is False:
Expand Down

0 comments on commit 6700537

Please sign in to comment.