Skip to content

Commit

Permalink
[FIX] : compatibility with numpy 2.0. Add _quantile_is_valid
Browse files Browse the repository at this point in the history
  • Loading branch information
shaupert committed Jun 20, 2024
1 parent 9bf1294 commit e0d336b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion maad/features/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import numpy as np
import pandas as pd
from scipy import interpolate
from numpy.lib.function_base import _quantile_is_valid
from scipy.optimize import root

# Import internal modules
Expand All @@ -37,6 +36,18 @@ def _interpolate_peak_location(pxx):
peak = xnew[ynew.argmax()]
amplitude = ynew[ynew.argmax()]
return peak, amplitude

def _quantile_is_valid(q):
# avoid expensive reductions, relevant for arrays with < O(1000) elements
if q.ndim == 1 and q.size < 10:
for i in range(q.size):
if not (0.0 <= q[i] <= 1.0):
return False
else:
if not (np.all(0 <= q) and np.all(q <= 1)):
return False
return True

#%%
# =============================================================================
# public functions
Expand Down

0 comments on commit e0d336b

Please sign in to comment.