Skip to content

Commit

Permalink
deprecation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
OverLordGoldDragon committed Jul 25, 2024
1 parent c829605 commit 192962a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#### FIXES
- `icwt` with `scaletype='linear'`: fix constant scaling factor
- `trapz` -> `trapezoid`; scipy deprecation, `scipy.integrate.trapz`
- numpy deprecation, fix `int()` upon 1D array (of size 1)

### 0.6.5

Expand Down
6 changes: 3 additions & 3 deletions ssqueezepy/utils/cwt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def infer_scaletype(scales):
if np.mean(np.abs(np.diff(np.log(scales), 2, axis=0))) < th_log:
scaletype = 'log'
# ceil to avoid faulty float-int roundoffs
nv = int(np.round(1 / np.diff(np.log2(scales), axis=0)[0]))
nv = int(np.round(1 / np.diff(np.log2(scales), axis=0)[0].squeeze()))

elif np.mean(np.abs(np.diff(scales, 2, axis=0))) < th_lin:
scaletype = 'linear'
Expand Down Expand Up @@ -620,11 +620,11 @@ def _integrate_near_zero():
# (.001 to .1 may not be negligible, however; better captured by logspace)
t = np.logspace(-15, -1, 1000)
arr = int_fn(t)
return integrate.trapz(arr, t)
return integrate.trapezoid(arr, t)

int_nz = _integrate_near_zero()
arr, t = _find_convergent_array()
return integrate.trapz(arr, t) + int_nz
return integrate.trapezoid(arr, t) + int_nz


def find_max_scale_alt(wavelet, N, min_cutoff=.1, max_cutoff=.8):
Expand Down
8 changes: 4 additions & 4 deletions ssqueezepy/utils/stft_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ def window_resolution(window):
apsi2 = np.abs(window)**2
apsih2s = np.abs(psihs)**2

var_w = integrate.trapz(ws**2 * apsih2s, ws) / integrate.trapz(apsih2s, ws)
var_t = integrate.trapz(t**2 * apsi2, t) / integrate.trapz(apsi2, t)
var_w = integrate.trapezoid(ws**2 * apsih2s, ws) / integrate.trapezoid(apsih2s, ws)
var_t = integrate.trapezoid(t**2 * apsi2, t) / integrate.trapezoid(apsi2, t)

std_w, std_t = np.sqrt(var_w), np.sqrt(var_t)
harea = std_w * std_t
Expand All @@ -226,11 +226,11 @@ def window_area(window, time=True, frequency=False):

if time:
t = np.arange(-len(window)/2, len(window)/2, step=1)
at = integrate.trapz(np.abs(window)**2, t)
at = integrate.trapezoid(np.abs(window)**2, t)
if frequency:
ws = fftshift(_xifn(1, len(window)))
apsih2s = np.abs(fftshift(fft(window)))**2
aw = integrate.trapz(apsih2s, ws)
aw = integrate.trapezoid(apsih2s, ws)

if time and frequency:
return at, aw
Expand Down
12 changes: 6 additions & 6 deletions ssqueezepy/wavelets.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ def _energy_wc(wavelet, scale, N, force_int):
scale = (4/pi) * wc_ct

w, psih, apsih2 = _params(wavelet, scale, N)
wc = (integrate.trapz(apsih2 * w) /
integrate.trapz(apsih2))
wc = (integrate.trapezoid(apsih2 * w) /
integrate.trapezoid(apsih2))

if use_formula:
wc *= (scale / scale_orig)
Expand Down Expand Up @@ -794,8 +794,8 @@ def _viz():
wce = center_frequency(wavelet, scale, force_int=force_int, kind='energy')

apsih2 = np.abs(psih)**2
var_w = (integrate.trapz((w - wce)**2 * apsih2, w) /
integrate.trapz(apsih2, w))
var_w = (integrate.trapezoid((w - wce)**2 * apsih2, w) /
integrate.trapezoid(apsih2, w))

std_w = np.sqrt(var_w)
if use_formula:
Expand Down Expand Up @@ -910,8 +910,8 @@ def _make_integration_t(wavelet, scale, N, min_decay, max_mult, min_mult):
psi = asnumpy(ifft(psih * (-1)**np.arange(Nt)))

apsi2 = np.abs(psi)**2
var_t = (integrate.trapz(t**2 * apsi2, t) /
integrate.trapz(apsi2, t))
var_t = (integrate.trapezoid(t**2 * apsi2, t) /
integrate.trapezoid(apsi2, t))

std_t = np.sqrt(var_t)
if use_formula:
Expand Down

0 comments on commit 192962a

Please sign in to comment.