Skip to content

Commit

Permalink
Fix other deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Jul 19, 2024
1 parent 8be31cb commit 973f655
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions abipy/core/kpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ def find_closest(self, obj):

dist = np.empty(len(self))
for i, kpt in enumerate(self):
dist[i] = kpt.lattice.norm(kpt.frac_coords - frac_coords)
dist[i] = float(kpt.lattice.norm(kpt.frac_coords - frac_coords))

ind = dist.argmin()
return ind, self[ind], np.copy(dist[ind])
Expand Down Expand Up @@ -1915,7 +1915,7 @@ def __init__(self, structure, mesh, is_shift, has_timrev):
for ik_bz, ir_gp_id in enumerate(mapping):
inds = np.where(uniq == ir_gp_id)
assert len(inds) == 1
self.bz2ibz[ik_bz] = inds[0]
self.bz2ibz[ik_bz] = int(inds[0])

def __str__(self):
return self.to_string()
Expand Down
2 changes: 1 addition & 1 deletion abipy/core/skw.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get_sampling(self, mesh, is_shift):
inds = np.where(uniq == ir_gp_id)
#print("inds", inds, "inds[0]", inds[0])
assert len(inds) == 1
bz2ibz[i] = inds[0]
bz2ibz[i] = int(inds[0])
#print("%3d ->%3d %s" % (i, ir_gp_id, (gp + [0.5, 0.5, 0.5]) / mesh))
#print("%3d ->%3d %s" % (i, ir_gp_id, (gp + kshift) / mesh))

Expand Down
7 changes: 7 additions & 0 deletions abipy/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,13 @@ def from_ase_atoms(cls, atoms) -> Structure:
import pymatgen.io.ase as aio
return aio.AseAtomsAdaptor.get_structure(atoms, cls=cls)

# FIXME: Temporary workaround to maintain compatbility with old pymatgen versions.
# m_elems was added in v2024.7.18
@property
def n_elems(self) -> int:
"""Number of types of atoms."""

return len(self.types_of_species)
def to_ase_atoms(self, calc=None):
"""
Returns ASE Atoms object from structure and attach calculator calc.
Expand Down
2 changes: 1 addition & 1 deletion abipy/iotools/tests/test_xsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_bxsf_write(self):
tmp_file = tempfile.TemporaryFile(mode="w+")

nsppol, nband, ndivs, fermie = 1, 2, (2,2,2), 0.0
energies = np.arange(nsppol * nband * np.product(ndivs))
energies = np.arange(nsppol * nband * np.prod(ndivs))
bxsf_write(tmp_file, self.mgb2, nsppol, nband, ndivs, energies, fermie, unit="Ha")

xsf_string = \
Expand Down
4 changes: 2 additions & 2 deletions abipy/iotools/xsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def xsf_write_data(file, structure, data, add_replicas=True, cplx_mode=None,
fdata = transpose_last3dims(data)
fgrid = fdata.shape[-3:]

cell = structure.lattice_vectors(space="r")
cell = structure.lattice.matrix
origin = np.zeros(3)

fwrite('BEGIN_BLOCK_DATAGRID_3D\n')
Expand Down Expand Up @@ -227,7 +227,7 @@ def bxsf_write(file, structure, nsppol, nband, ndivs, ucdata_sbk, fermie, unit="
fw("0 0 0\n") # Unshifted meshes are not supported.

# Reciprocal lattice vectors in Ang^{-1}
gcell = structure.lattice_vectors("g")
gcell = structure.lattice.reciprocal_lattice.matrix
for i in range(3):
fw('%f %f %f\n' % tuple(gcell[i]))

Expand Down
2 changes: 1 addition & 1 deletion abipy/lumi/deltaSCF.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def lineshape_1D_zero_temp(self,energy_range=[0.5,5],max_m=25,phonon_width=0.01,
A=A*E_x**3

if normalized=="Area":
C = 1 / (simps(A, E_x))
C = 1 / (simps(A, x=E_x))
if normalized=="Sum":
C=1/(max(A))

Expand Down
6 changes: 3 additions & 3 deletions abipy/panels/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ def ply(fig, sizing_mode='stretch_both', with_chart_studio=False, with_help=Fals
showLink=True,
plotlyServerURL="https://chart-studio.plotly.com",
)

plotly_fig = mpl_to_ply(fig)

plotly_pane = pn.pane.Plotly(plotly_fig, config=config)
ca(plotly_pane)

Expand Down Expand Up @@ -1566,7 +1566,7 @@ class BaseRobotPanel(AbipyParameterized):
def __init__(self, robot, **params):
self.robot = robot
self.compare_params_btn = pnw.Button(name="Compare structures", button_type='primary')
self.transpose_params = pnw.Checkbox(name='Transpose table', default=True)
self.transpose_params = pnw.Checkbox(name='Transpose table', value=True)

super().__init__(**params)

Expand Down

0 comments on commit 973f655

Please sign in to comment.