Skip to content

Commit

Permalink
Numpy2 support (#479)
Browse files Browse the repository at this point in the history
* Update for 3.12

* Updated workflows and changelog

* Upload to 3.12

* Numpy 2.0 compatibility updates

* Update Changelog
  • Loading branch information
HKaras authored Jul 2, 2024
1 parent 21df49d commit 534495e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
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

0 comments on commit 534495e

Please sign in to comment.