Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/mess_io/reader/ped.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
from ioformat import remove_comment_lines
from mess_io.reader._label import name_label_dct
from automol.util.dict_ import invert
# AVC: Backward compatibility for numpy < 2.0, where the function is called `trapz`
try:
from numpy import trapezoid
except ImportError:
from numpy import trapz as trapezoid


def ped_names(input_str):
Expand Down Expand Up @@ -87,7 +92,7 @@ def prob_en_single(probability, energy, del_neg = False):

# prob_en = prob_en[prob_en > 0]
if del_neg:
if np.trapz(prob_en.values, x=prob_en.index) < 0:
if trapezoid(prob_en.values, x=prob_en.index) < 0:
# I don't know how to treat negative probabilities
# alternative: set the absolute value? or do nothing
prob_en *= 0
Expand All @@ -113,7 +118,7 @@ def prob_en_single(probability, energy, del_neg = False):
# prob_en = prob_en[prob_en[prob_en < 0].index[-1]+1:]
# print(prob_en, '\n')
# integrate with trapz
prob_en /= abs(np.trapz(prob_en.values, x=prob_en.index))
prob_en /= abs(trapezoid(prob_en.values, x=prob_en.index))

# if issues : keep only max value like dirac delta
if any(np.isnan(prob_en.values)) or any(np.isinf(prob_en.values)):
Expand Down
Loading