Skip to content

Commit

Permalink
Merge pull request #66 from ken-lauer/fix_numpy2
Browse files Browse the repository at this point in the history
FIX: numpy2 support
  • Loading branch information
ChristopherMayes authored Oct 2, 2024
2 parents 4733949 + 2a88a4d commit 6f108d7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pmd_beamphysics/fields/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
import numpy as np


# Numpy migration per https://numpy.org/doc/stable/numpy_2_0_migration_guide.html
if np.lib.NumpyVersion(np.__version__) >= '2.0.0':
from numpy import trapezoid
else:
# Support 'trapz' from numpy 1.0
from numpy import trapz as trapezoid


#----------------------
# Analysis
Expand Down Expand Up @@ -36,7 +43,7 @@ def accelerating_voltage_and_phase(z, Ez, frequency):
fz =Ez*np.exp(-1j*k*z)

# Integrate
Z = np.trapz(fz, z)
Z = trapezoid(fz, z)

# Max voltage at phase
voltage = np.abs(Z)
Expand Down

0 comments on commit 6f108d7

Please sign in to comment.