Skip to content

Commit d5f79b4

Browse files
committed
Fix use of np.trapezoid
1 parent 6caaff6 commit d5f79b4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

openpmd_viewer/addons/pic/lpa_diagnostics.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,12 @@ def get_spectrogram( self, t=None, iteration=None, pol=None,
10411041
T = tmax - tmin
10421042
dt = T / Nz
10431043
# Normalize the Envelope
1044-
env /= np.sqrt(np.trapezoid(env ** 2, dx=dt))
1044+
# Note that np.trapz has been deprecated and is replaced by np.trapezoid in numpy2
1045+
try:
1046+
trapezoid = np.trapezoid
1047+
except AttributeError:
1048+
trapezoid = np.trapz
1049+
env /= np.sqrt(trapezoid(env ** 2, dx=dt))
10451050
# Allocate array for the gating function and the spectrogran
10461051
E_shift = np.zeros_like(E)
10471052
spectrogram = np.zeros((2 * Nz, Nz))

0 commit comments

Comments
 (0)