Skip to content

Commit

Permalink
it seems that scipy 1.14.0rc1 broke backward compatibility in simps a…
Browse files Browse the repository at this point in the history
…nd cumtrapz
  • Loading branch information
gmatteo committed Jun 15, 2024
1 parent a67d8bc commit 865b28b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 12 deletions.
5 changes: 4 additions & 1 deletion abipy/core/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
from monty.functools import lazy_property
from monty.string import marquee # is_string, list_strings,
from scipy.interpolate import UnivariateSpline
from scipy.integrate import cumtrapz
try :
from scipy.integrate import cumtrapz
except ImportError:
from scipy.integrate import cumulative_trapezoid as cumtrapz
from abipy.data import nist_database
from abipy.tools.serialization import pmg_serialize

Expand Down
6 changes: 5 additions & 1 deletion abipy/core/func1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ def integral(self, start=0, stop=None) -> Function1D:
"""
if stop is None: stop = len(self.values) + 1
x, y = self.mesh[start:stop], self.values[start:stop]
from scipy.integrate import cumtrapz
try :
from scipy.integrate import cumtrapz
except ImportError:
from scipy.integrate import cumulative_trapezoid as cumtrapz

integ = cumtrapz(y, x=x, initial=0.0)

return self.__class__(x, integ)
Expand Down
6 changes: 5 additions & 1 deletion abipy/core/skw.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ def get_edos(self, kmesh, is_shift=None, method="gaussian", step=0.1, width=0.2,
values[spin] += wtk * gaussian(wmesh, width, center=eigens[spin, ik, band])

# Compute IDOS
integral = scipy.integrate.cumtrapz(values, x=wmesh, initial=0.0)
try :
from scipy.integrate import cumtrapz
except ImportError:
from scipy.integrate import cumulative_trapezoid as cumtrapz
integral = cumtrapz(values, x=wmesh, initial=0.0)

else:
raise ValueError("Method %s is not supported" % method)
Expand Down
9 changes: 8 additions & 1 deletion abipy/eph/a2f.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
import abipy.core.abinit_units as abu

from collections import OrderedDict
from scipy.integrate import cumtrapz, simps
try:
from scipy.integrate import cumtrapz
except ImportError:
from scipy.integrate import cumulative_trapezoid as cumtrapz
try:
from scipy.integrate import simps
except ImportError:
from scipy.integrate import simpson as simps
#from typing import Any
from monty.string import marquee, list_strings
from monty.functools import lazy_property
Expand Down
7 changes: 4 additions & 3 deletions abipy/lumi/deltaSCF.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
#from mpl_toolkits.mplot3d import Axes3D
import math
from mpmath import coth
from scipy.integrate import simps
try:
from scipy.integrate import simps
except ImportError:
from scipy.integrate import simpson as simps
#from scipy.special import factorial
from abipy.tools.plotting import get_ax_fig_plt, add_fig_kwargs,get_axarray_fig_plt
import abipy.core.abinit_units as abu
Expand Down Expand Up @@ -578,8 +581,6 @@ def draw_displacements_vesta(self,in_path, mass_weighted = False,
print(f"Vesta files created and stored in : \n {os.getcwd()}/{out_path}")

return



@add_fig_kwargs
def displacements_visu(self,a_g=10,**kwargs):
Expand Down
5 changes: 4 additions & 1 deletion abipy/lumi/lineshape.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import numpy as np
from numpy import fft
from scipy import signal
from scipy.integrate import simps
try:
from scipy.integrate import simps
except ImportError:
from scipy.integrate import simpson as simps
from pymatgen.io.phonopy import get_pmg_structure
from abipy.tools.plotting import get_ax_fig_plt,add_fig_kwargs
from abipy.embedding.utils_ifc import clean_structure
Expand Down
6 changes: 4 additions & 2 deletions abipy/tools/bessel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

from scipy.special import spherical_jn
from scipy.interpolate import UnivariateSpline
from scipy.integrate import simps # cumtrapz, quad

try:
from scipy.integrate import simps
except ImportError:
from scipy.integrate import simpson as simps

_DEFAULTS = {"numq": 3001, "numr": 3001}

Expand Down
4 changes: 2 additions & 2 deletions abipy/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,9 @@ def plot(self, ax_mat=None, fontsize=8, **kwargs) -> Figure:
ytol_string = str(ytol)
#print("ytol_string:", ytol_string, "pre_str:", pre_str, "ytol_string:", ytol_string, "xx:", xx)
if xx is not None:
s = "x: %.1f for $\Delta$: %s" % (xx, ytol_string)
s = r"x: %.1f for $\Delta$: %s" % (xx, ytol_string)
else:
s = "x: ?? for $\Delta$: %s" % (ytol_string)
s = r"x: ?? for $\Delta$: %s" % (ytol_string)
title += pre_str + s

ax2.set_title(title, fontsize=fontsize)
Expand Down

0 comments on commit 865b28b

Please sign in to comment.