From 973f655f930c9410b4b91f34cdfaa833df80079f Mon Sep 17 00:00:00 2001 From: Matteo Giantomassi Date: Fri, 19 Jul 2024 23:50:19 +0200 Subject: [PATCH] Fix other deprecation warnings --- abipy/core/kpoints.py | 4 ++-- abipy/core/skw.py | 2 +- abipy/core/structure.py | 7 +++++++ abipy/iotools/tests/test_xsf.py | 2 +- abipy/iotools/xsf.py | 4 ++-- abipy/lumi/deltaSCF.py | 2 +- abipy/panels/core.py | 6 +++--- 7 files changed, 17 insertions(+), 10 deletions(-) diff --git a/abipy/core/kpoints.py b/abipy/core/kpoints.py index de69b4878..7c7675ab6 100644 --- a/abipy/core/kpoints.py +++ b/abipy/core/kpoints.py @@ -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]) @@ -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() diff --git a/abipy/core/skw.py b/abipy/core/skw.py index 2a2a3dc19..321411fb5 100644 --- a/abipy/core/skw.py +++ b/abipy/core/skw.py @@ -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)) diff --git a/abipy/core/structure.py b/abipy/core/structure.py index 328280f5e..02ae2159c 100644 --- a/abipy/core/structure.py +++ b/abipy/core/structure.py @@ -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. diff --git a/abipy/iotools/tests/test_xsf.py b/abipy/iotools/tests/test_xsf.py index 4d1030005..8b655af43 100644 --- a/abipy/iotools/tests/test_xsf.py +++ b/abipy/iotools/tests/test_xsf.py @@ -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 = \ diff --git a/abipy/iotools/xsf.py b/abipy/iotools/xsf.py index ef15719a7..845bf5fbc 100644 --- a/abipy/iotools/xsf.py +++ b/abipy/iotools/xsf.py @@ -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') @@ -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])) diff --git a/abipy/lumi/deltaSCF.py b/abipy/lumi/deltaSCF.py index a52e640b9..bd124274d 100644 --- a/abipy/lumi/deltaSCF.py +++ b/abipy/lumi/deltaSCF.py @@ -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)) diff --git a/abipy/panels/core.py b/abipy/panels/core.py index 3ee921649..885c16667 100644 --- a/abipy/panels/core.py +++ b/abipy/panels/core.py @@ -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) @@ -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)