Skip to content

Commit

Permalink
DEP: drop scipy as a hard dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Nov 24, 2024
1 parent a530404 commit 4429e52
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions nonos/api/satellite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import warnings
from importlib.util import find_spec
from pathlib import Path
from typing import TYPE_CHECKING, Optional

Expand All @@ -23,8 +24,6 @@ def file_analysis(
directory: Optional["PathT"] = None,
norb: Optional[int] = None,
) -> "FloatArray":
from scipy.ndimage import uniform_filter1d

if directory is None:
directory = Path.cwd()
else:
Expand All @@ -46,8 +45,15 @@ def file_analysis(
analysis = ini["Output"]["analysis"]
rpini = ini["Planet"]["dpl"]
Ntmean = round(norb * 2 * np.pi * pow(rpini, 1.5) / analysis)
for i in range(1, len(columns) - 1):
columns[i] = uniform_filter1d(columns[i], Ntmean)
if find_spec("scipy") is not None:
from scipy.ndimage import uniform_filter1d

for i, column in enumerate(columns):
columns[i] = uniform_filter1d(column, Ntmean)
else:
# fallback to numpy if scipy isn't available (less performant)
for i, column in enumerate(columns):
columns[i] = np.convolve(column, np.ones_like(column), mode="valid")
else:
raise NotImplementedError(
f"moving average on {norb} orbits is not implemented for the recipe {recipe}"
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dependencies = [
"numpy>=1.19.3",
"packaging>=20.0",
"rich>=10.13.0",
"scipy>=1.6.1",
"typing_extensions >= 4.4.0 ; python_version < '3.12'",
]

Expand Down
1 change: 1 addition & 0 deletions requirements/tests_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ cblind>=2.3.0
cmocean>=3.0.3
cmyt>=2.0.0
numexpr>=2.8.3
scipy>=1.6.1

0 comments on commit 4429e52

Please sign in to comment.