diff --git a/.travis.yml b/.travis.yml index 09b1d243..02b1bb4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,11 @@ language: python matrix: include: - python: 3.5 - env: PYTHON=3.5 PCKGS="numexpr matplotlib" CHAN="defaults" TEST="--mpl" INST="pytest-mpl" + env: PYTHON=3.5 PCKGS="numexpr matplotlib" CHAN="defaults" TEST="--mpl" INST="pytest-mpl scooby" - python: 3.6 - env: PYTHON=3.6 PCKGS="numexpr matplotlib" CHAN="defaults" TEST="--mpl" INST="pytest-mpl" + env: PYTHON=3.6 PCKGS="numexpr matplotlib" CHAN="defaults" TEST="--mpl" INST="pytest-mpl scooby" - python: 3.6 # => 3.7 - env: PYTHON=3.7 PCKGS="numexpr matplotlib" CHAN="defaults" TEST="--mpl" INST="pytest-mpl" + env: PYTHON=3.7 PCKGS="numexpr matplotlib" CHAN="defaults" TEST="--mpl" INST="pytest-mpl scooby" - python: 3.6 # => 3.6 with conda-forge env: PYTHON=3.6 PCKGS="numexpr matplotlib" CHAN="conda-forge" TEST="--mpl" INST="pytest-mpl" - python: 3.6 # => 3.6 with without matplotlib, numexpr @@ -30,7 +30,7 @@ install: # Install and activate environment, install packages - conda create -q -n test-environment -c $CHAN python=$PYTHON numpy scipy pytest pytest-cov $PCKGS - source activate test-environment - - pip install coveralls pytest-flake8 scooby $INST + - pip install coveralls pytest-flake8 $INST - python setup.py install - cp tests/matplotlibrc . diff --git a/empymod/utils.py b/empymod/utils.py index d7a2a1f0..2f6c0add 100644 --- a/empymod/utils.py +++ b/empymod/utils.py @@ -30,13 +30,20 @@ # Mandatory imports -import scooby import warnings import numpy as np from scipy import special from datetime import timedelta from timeit import default_timer +# scooby is a soft dependency for empymod +try: + from scooby import Report as ScoobyReport +except ImportError: + class ScoobyReport: + def __init__(self, additional, core, optional, ncol, text_width, sort): + print("\n* WARNING :: `empymod.Report` requires `scooby`." + "\n Install it via `pip install scooby`.\n") # Optional imports try: @@ -1977,10 +1984,10 @@ def spline_backwards_hankel(ht, htarg, opt): # 6. Report -class Report(scooby.Report): +class Report(ScoobyReport): r"""Print date, time, and version information. - Use scooby to print date, time, and package version information in any + Use ``scooby`` to print date, time, and package version information in any environment (Jupyter notebook, IPython console, Python console, QT console), either as html-table (notebook) or as plain text (anywhere). @@ -2010,6 +2017,13 @@ class Report(scooby.Report): Sort the packages when the report is shown + NOTE + ---- + + The package ``scooby`` has to be installed in order to use ``Report``: + ``pip install scooby``. + + Examples -------- >>> import pytest diff --git a/requirements.txt b/requirements.txt index 1ade0030..bc5b85f4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,3 @@ numpydoc >= 0.9 # scipy 0.19.0 has a memory leak in quad # github.com/scipy/scipy/pull/7216 scipy != 0.19.0 - -scooby >= 0.3.0 diff --git a/runtests.sh b/runtests.sh index 2bf00ea9..520b29e9 100755 --- a/runtests.sh +++ b/runtests.sh @@ -26,7 +26,7 @@ PCKGS="numpy scipy pytest pytest-cov" NMXPR="numexpr matplotlib IPython" STR2="** WITH numexpr/matplotlib/IPython " PROPS="--mpl --flake8" -INST="pytest-flake8 pytest-mpl" +INST="pytest-flake8 pytest-mpl scooby" SD="_soft-dep" WARN="" @@ -94,7 +94,7 @@ for i in ${PYTHON3VERSION[@]}; do # Install flake8 if [ ! -d "$HOME/anaconda3/envs"+$NAME ]; then - pip install scooby $INST &> $PRINT + pip install $INST &> $PRINT fi # Run tests diff --git a/setup.py b/setup.py index df30f229..dbd4c427 100644 --- a/setup.py +++ b/setup.py @@ -26,6 +26,5 @@ install_requires=[ 'numpy', 'scipy!=0.19.0', - 'scooby>=0.3.0' ], ) diff --git a/tests/test_utils.py b/tests/test_utils.py index 0783cd9d..d5e85221 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,3 @@ -import scooby import pytest import numpy as np from numpy.testing import assert_allclose @@ -10,6 +9,12 @@ use_vml = False use_ne_eval = False +# Optional import +try: + import scooby +except ImportError: + scooby = False + from empymod import utils, filters @@ -1035,23 +1040,31 @@ def test_spline_backwards_hankel(): def test_report(capsys): + out, _ = capsys.readouterr() # Empty capsys # Reporting is now done by the external package scooby. # We just ensure the shown packages do not change (core and optional). - out1 = utils.Report() - out2 = scooby.Report( - core=['numpy', 'scipy', 'empymod'], - optional=['numexpr', 'IPython', 'matplotlib'], - ncol=3) + if scooby: + out1 = utils.Report() + out2 = scooby.Report( + core=['numpy', 'scipy', 'empymod'], + optional=['numexpr', 'IPython', 'matplotlib'], + ncol=3) + + # Ensure they're the same; exclude time to avoid errors. + assert out1.__repr__()[115:] == out2.__repr__()[115:] - # Ensure they're the same; exclude time to avoid errors. - assert out1.__repr__()[115:] == out2.__repr__()[115:] + else: # soft dependency + _ = utils.Report() + out, _ = capsys.readouterr() # Empty capsys + assert 'WARNING :: `empymod.Report` requires `scooby`' in out def test_versions_backwards(): - out1 = utils.Report() - out2 = utils.Versions() - out3 = utils.versions() + if scooby: + out1 = utils.Report() + out2 = utils.Versions() + out3 = utils.versions() - assert out1.__repr__() == out2.__repr__() - assert out1.__repr__() == out3.__repr__() + assert out1.__repr__() == out2.__repr__() + assert out1.__repr__() == out3.__repr__()