Skip to content

Commit

Permalink
Make scooby a requirement (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
prisae authored Mar 1, 2024
1 parent acddeaa commit e7c25e5
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 37 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- python-version: "3.10"
name: full
os: ubuntu
conda: "numba 'matplotlib>=3.3' scipy scooby pytest-mpl"
conda: "numba 'matplotlib>=3.3' scipy pytest-mpl"
test: "--mpl"
- python-version: "3.11"
name: plain
Expand All @@ -59,7 +59,7 @@ jobs:
- python-version: "3.11"
name: full
os: ubuntu
conda: "numba 'matplotlib>=3.3' scipy scooby pytest-mpl"
conda: "numba 'matplotlib>=3.3' scipy pytest-mpl"
test: "--mpl"
- python-version: "3.12"
name: plain
Expand All @@ -69,7 +69,7 @@ jobs:
- python-version: "3.12"
name: full
os: ubuntu
conda: "numba 'matplotlib' scipy scooby pytest-mpl"
conda: "numba 'matplotlib' scipy pytest-mpl"
test: "--mpl"

env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
conda config --show-sources
conda config --show
conda info -a
conda install numba "scipy!=1.9.0" pytest pytest-console-scripts scooby setuptools-scm
conda install numba "scipy!=1.9.0" pytest pytest-console-scripts setuptools-scm
- name: Conda list
shell: bash -l {0}
Expand Down
23 changes: 20 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@ Version 2
~~~~~~~~~


v2.2.x
v2.3.x
""""""

latest
------

v2.3.0: libdlf and scooby
-------------------------

**2024-03-01**

The digital linear filters are outsourced to libdlf, reducing the lines of code
of empymod by over 50%. In addition to the new requirement libdlf, scooby is
added as a requirement. Most user questions can be adressed much better if they
provide the output of ``empymod.Report()`` - however, most users do not have
scooby installed. Having it as a requirement will make support smoother. Both
new requirements are very lightweight modules, having at most numpy as a
dependency.


- Filters:

Expand All @@ -31,6 +43,7 @@ latest
- SciPy 1.9
- Numba 0.53
- libdlf (NEW requirement)
- scooby (NEW requirement)

- Testing: added Python 3.12, dropped Python 3.8.

Expand All @@ -40,6 +53,10 @@ latest



v2.2.x
""""""


v2.2.2: Flexible dipole coordinates
-----------------------------------

Expand Down
10 changes: 1 addition & 9 deletions empymod/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,7 @@

# Relative imports
from empymod import filters, transform

# 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")
from scooby import Report as ScoobyReport

# Version: We take care of it here instead of in __init__, so we can use it
# within the package itself (logs).
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
-r requirements.txt

# SOFT DEPENDENCIES
scooby
matplotlib

# SETUP RELATED
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"scipy>=1.9",
"numba>=0.53",
"libdlf",
"scooby",
],
use_scm_version={
"root": ".",
Expand Down
29 changes: 9 additions & 20 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import sys
import pytest
import scooby
import subprocess
import numpy as np
from numpy.testing import assert_allclose

# Optional import
try:
import scooby
except ImportError:
scooby = False

from empymod import utils, filters


Expand Down Expand Up @@ -1196,20 +1191,14 @@ def test_report(capsys):

# Reporting is now done by the external package scooby.
# We just ensure the shown packages do not change (core and optional).
if scooby:
out1 = scooby.Report(
core=['numpy', 'scipy', 'numba', 'empymod'],
optional=['IPython', 'matplotlib'],
ncol=3)
out2 = utils.Report()

# 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
out1 = scooby.Report(
core=['numpy', 'scipy', 'numba', 'empymod'],
optional=['IPython', 'matplotlib'],
ncol=3)
out2 = utils.Report()

# Ensure they're the same; exclude time to avoid errors.
assert out1.__repr__()[115:] == out2.__repr__()[115:]


@pytest.mark.skipif(not sys.platform.startswith('linux'), reason="Not Linux.")
Expand Down

0 comments on commit e7c25e5

Please sign in to comment.