Skip to content

Commit

Permalink
Use new integration function from Numpy 2.0.0 on
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobachetti committed Jul 5, 2024
1 parent d05b341 commit 3544643
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion stingray/multitaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
from .lightcurve import Lightcurve
from .utils import rebin_data, simon, fft, rfft, rfftfreq

try:
integration_func = np.trapezoid
except AttributeError:
# < Numpy 2.0.0
integration_func = np.trapz

__all__ = ["Multitaper"]

# Inspired from nitime (https://nipy.org/nitime/)
Expand Down Expand Up @@ -460,7 +466,7 @@ def _get_adaptive_psd(self, freq_response, eigvals, max_iter=150):

psd_est = self.psd_from_freq_response(freq_response, sqrt_eigvals[:, np.newaxis])

var = np.trapz(psd_est, dx=np.pi / n_freqs) / (2 * np.pi)
var = integration_func(psd_est, dx=np.pi / n_freqs) / (2 * np.pi)

Check warning on line 469 in stingray/multitaper.py

View check run for this annotation

Codecov / codecov/patch

stingray/multitaper.py#L469

Added line #L469 was not covered by tests
del psd_est

psd = np.empty(n_freqs)
Expand Down

0 comments on commit 3544643

Please # to comment.