Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy2 support #479

Merged
merged 14 commits into from
Jul 2, 2024
2 changes: 1 addition & 1 deletion deerlab/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def percentile(self,p):
cdf = np.cumsum(pdf)
cdf /= max(cdf)
# Eliminate duplicates
cdf, index = np.lib.arraysetops.unique(cdf,return_index=True)
cdf, index = np.unique(cdf,return_index=True)
# Interpolate requested percentile
x[n] = np.interp(p/100,cdf,values[index])

Expand Down
2 changes: 1 addition & 1 deletion deerlab/dd_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _multigaussfun(r,r0,sig):
P = np.sqrt(1/(2*np.pi))*1/sig*np.exp(-0.5*((r.T-r0)/sig)**2)
if not np.all(P==0):
# Normalization
P = np.squeeze(P)/np.sum([np.trapz(c,r) for c in P.T])
P = np.squeeze(P)/np.sum([np.trapezoid(c,r) for c in P.T])
else:
P = np.squeeze(P)
return P
Expand Down
2 changes: 1 addition & 1 deletion deerlab/diststats.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def normalize(P):
# Percentile function
def pctile(r,P,p):
cdf = cumtrapz(normalize(P),r,initial=0)
cdf, index = np.lib.arraysetops.unique(cdf,return_index=True)
cdf, index = np.unique(cdf,return_index=True)
rpctile = np.interp(p/100,cdf,r[index])
return rpctile
# Expectation operator function
Expand Down
4 changes: 3 additions & 1 deletion docsrc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ Release ``v1.1.3`` - Ongoing
------------------------------------------
- |fix| : Removes unnecessary files from the docs
- |efficiency| : Improves the performance of the ``dipolarkernel`` function by 10-30% (:pr:`473`), by caching the interpolation of he effective dipolar evolution time vector.
- |fix| : add support for Python 3.12
- |fix| : Add support for Python 3.12
- |fix| : Adds support for Numpy 2.0


Release ``v1.1.2`` - November 2023
------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion test/test_dipolarkernel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import numpy as np
from numpy import pi, inf, NaN
from numpy import pi, inf
from deerlab.bg_models import bg_hom3d,bg_exp
from deerlab.dd_models import dd_gauss
from deerlab.dipolarkernel import dipolarkernel,elementarykernel_twospin
Expand Down
Loading