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

Show FutureWarning and DeprecationWarning for pytest #4138

Draft
wants to merge 40 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
545e2a5
show FutureWarning and DeprecationWarning
DanielYang59 Oct 26, 2024
64c99d8
TODO: mark FutureWarning and DeprecationWarning for this PR
DanielYang59 Oct 26, 2024
3a79e83
Merge branch 'master' into show-deprecation-warn
DanielYang59 Oct 27, 2024
c213125
from pymatgen.core.interface import GrainBoundaryGenerator
DanielYang59 Oct 27, 2024
bc8d0ae
Suppress DeprecationWarnings on pkg_resources from pybtex
DanielYang59 Oct 27, 2024
52348ea
suppress all warning from pybtex
DanielYang59 Oct 27, 2024
0d697e9
use single quote
DanielYang59 Oct 27, 2024
35ad4ca
ignore Userwarning
DanielYang59 Oct 27, 2024
0aad506
bump plotly to avoid SyntaxWarning
DanielYang59 Oct 27, 2024
0dd7e40
DeprecationWarning: Testing an element's truth value will always retu…
DanielYang59 Oct 27, 2024
47bca8c
suppress spglib.get_symmetry
DanielYang59 Oct 27, 2024
b4bee46
fix get_vasp_input
DanielYang59 Oct 27, 2024
6a62d63
add comment
DanielYang59 Oct 27, 2024
0dad00c
replace piezo sensitivity
DanielYang59 Oct 27, 2024
f693604
suppress warning
DanielYang59 Oct 27, 2024
f84bfd3
suppress known bader warning
DanielYang59 Oct 27, 2024
4b92c08
add comment for something Im unable to fix
DanielYang59 Oct 27, 2024
1d9f673
fix lammps input
DanielYang59 Oct 27, 2024
bc5024f
n_elems
DanielYang59 Oct 27, 2024
846c5fa
simplify warning filter in test
DanielYang59 Oct 27, 2024
a122ec9
fix get_vasp_input
DanielYang59 Oct 27, 2024
bc755b2
avoid warning leakage
DanielYang59 Oct 27, 2024
8c1cee5
fix lobster
DanielYang59 Oct 27, 2024
401df09
replace phonopy
DanielYang59 Oct 27, 2024
856bfc0
revert filter warn for that we might want to fix
DanielYang59 Oct 27, 2024
050bf49
fix pandas na filter
DanielYang59 Oct 27, 2024
d5a749d
enhance filter msg
DanielYang59 Oct 27, 2024
2f54d9d
NEED CONFIRM: replace plotly colorbar
DanielYang59 Oct 27, 2024
80d3d6a
suppress intended test for MaterialsProjectCompatibility
DanielYang59 Oct 27, 2024
96ff0e3
fix pd.read_json
DanielYang59 Oct 27, 2024
1ec42d9
replace matrix with array
DanielYang59 Oct 27, 2024
6ed8a65
suppress too many figure warning
DanielYang59 Oct 27, 2024
a1538f9
fix openff
DanielYang59 Oct 27, 2024
3dd3a3b
clean up warning filter
DanielYang59 Oct 27, 2024
241621a
add comment
DanielYang59 Oct 27, 2024
041c874
filter intended usage
DanielYang59 Oct 27, 2024
e4df7b3
clean up warn filter
DanielYang59 Oct 27, 2024
e01dec6
revert plotly bump
DanielYang59 Oct 27, 2024
e69e3f0
enhance comment
DanielYang59 Oct 27, 2024
c9e4301
Merge branch 'master' into show-deprecation-warn
DanielYang59 Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies = [
"joblib>=1",
"matplotlib>=3.8",
"monty>=2024.7.29",
"networkx>=3", # PR #4116
"networkx>=3", # PR4116
"palettable>=3.3.3",
"pandas>=2",
"plotly>=4.5.0",
Expand Down Expand Up @@ -252,7 +252,17 @@ docstring-code-format = true
"dev_scripts/*" = ["D"]

[tool.pytest.ini_options]
addopts = "--durations=30 --quiet -r xXs --color=yes -p no:warnings --import-mode=importlib"
addopts = "--durations=30 --quiet -r xXs --color=yes --import-mode=importlib"
filterwarnings = [
# NOTE: the last matching option is used
"ignore::Warning", # Ignore all Warning
"default::FutureWarning", # Show FutureWarnings
"default::DeprecationWarning", # Show DeprecationWarnings
# TODO: pybtex (perhaps some others) emits the following warnings
'ignore:pkg_resources is deprecated as an API:DeprecationWarning',
'ignore:distutils Version classes are deprecated:DeprecationWarning',
'ignore:Deprecated call to `pkg_resources.declare_namespace:DeprecationWarning',
]

[tool.coverage.run]
parallel = true
Expand Down
2 changes: 1 addition & 1 deletion src/pymatgen/alchemy/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def get_vasp_input(self, vasp_input_set: type[VaspInputSet] = MPRelaxSet, **kwar
to create VASP input files from structures
**kwargs: All keyword args supported by the VASP input set.
"""
dct = vasp_input_set(self.final_structure, **kwargs).get_vasp_input()
DanielYang59 marked this conversation as resolved.
Show resolved Hide resolved
dct = vasp_input_set(self.final_structure, **kwargs).get_input_set()
dct["transformations.json"] = json.dumps(self.as_dict())
return dct

Expand Down
2 changes: 2 additions & 0 deletions src/pymatgen/analysis/magnetism/heisenberg.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ def _get_exchange_df(self):

# Ignore the row if it is a duplicate to avoid singular matrix
# Create a temporary DataFrame with the new row
ex_mat = ex_mat.dropna(how="all", axis=1)
Copy link
Contributor Author

@DanielYang59 DanielYang59 Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure about this change (regarding the axis), but it should be the columns from the warning message:

  /Users/yang/developer/pymatgen/src/pymatgen/analysis/magnetism/heisenberg.py:325: 
FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. 
In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. 
To retain the old behavior, exclude the relevant entries before the concat operation.
    temp_df = pd.concat([ex_mat, ex_row], ignore_index=True)

ex_row = ex_row.dropna(how="all", axis=1)
temp_df = pd.concat([ex_mat, ex_row], ignore_index=True)
if temp_df[j_columns].equals(temp_df[j_columns].drop_duplicates(keep="first")):
e_index = self.ordered_structures.index(sgraph.structure)
Expand Down
8 changes: 4 additions & 4 deletions src/pymatgen/analysis/piezo_sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,17 +620,17 @@ def get_rand_FCM(self, asum=15, force=10):
for n in range(n_sites):
dyn_mass[m][n] = dyn[m][n] * np.sqrt(masses[m]) * np.sqrt(masses[n])

supercell = pn_struct.get_supercell()
primitive = pn_struct.get_primitive()
supercell = pn_struct.supercell
primitive = pn_struct.primitive

converter = dyntofc.DynmatToForceConstants(primitive, supercell)

dyn = np.reshape(np.swapaxes(dyn_mass, 1, 2), (n_sites * 3, n_sites * 3))

converter.set_dynamical_matrices(dynmat=[dyn])
converter.dynamical_matrices = [dyn]

converter.run()
return converter.get_force_constants()
return converter.force_constants
DanielYang59 marked this conversation as resolved.
Show resolved Hide resolved


def get_piezo(BEC, IST, FCM, rcond=0.0001):
Expand Down
9 changes: 7 additions & 2 deletions src/pymatgen/analysis/quasiharmonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import numpy as np
from monty.dev import deprecated
from scipy.constants import physical_constants
from scipy.integrate import quadrature
from scipy.integrate import quad
from scipy.misc import derivative
from scipy.optimize import minimize

Expand Down Expand Up @@ -261,7 +261,7 @@ def debye_integral(y):
# 6.4939394 (from wolfram alpha).
factor = 3.0 / y**3
if y < 155:
integral = quadrature(lambda x: x**3 / (np.exp(x) - 1.0), 0, y)
integral = quad(lambda x: x**3 / (np.exp(x) - 1.0), 0, y)
return next(iter(integral)) * factor
return 6.493939 * factor

Expand Down Expand Up @@ -299,6 +299,11 @@ def gruneisen_parameter(self, temperature, volume):
d3EdV3 = np.polyder(p, 3)(volume)
else:
func = self.ev_eos_fit.func

# TODO: scipy.misc.derivative is deprecated in SciPy v1.10.0;
# and will be completely removed in SciPy v1.12.0.
# You may consider using findiff: https://github.com/maroba/findiff
# or numdifftools: https://github.com/pbrod/numdifftools
dEdV = derivative(func, volume, dx=1e-3)
d2EdV2 = derivative(func, volume, dx=1e-3, n=2, order=5)
d3EdV3 = derivative(func, volume, dx=1e-3, n=3, order=7)
Expand Down
2 changes: 1 addition & 1 deletion src/pymatgen/analysis/wulff.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def get_plotly(
x=[0],
y=[0],
z=[0],
colorbar=go.ColorBar(
Copy link
Contributor Author

@DanielYang59 DanielYang59 Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not experienced with plotly, could any one help me confirm this?

plotly.graph_objs.ColorBar is deprecated.
  Please replace it with one of the following more specific types
    - plotly.graph_objs.scatter.marker.ColorBar
    - plotly.graph_objs.surface.ColorBar
    - etc.

Looks like the correct colorbar for mesh3d:

# Add colorbar
color_scale = sorted(color_scale, key=lambda c: c[0])
colorbar = go.Mesh3d(
x=[0],
y=[0],
z=[0],
colorbar=go.ColorBar(
title={
"text": f"Surface energy {units}",
"side": "right",
"font": {"size": 25},
},
ticktext=ticktext,
tickvals=tickvals,
),

colorbar=go.mesh3d.ColorBar(
title={
"text": f"Surface energy {units}",
"side": "right",
Expand Down
20 changes: 12 additions & 8 deletions src/pymatgen/io/lammps/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,14 +913,18 @@ def write_inputs(self, output_dir: str, **kwargs) -> None:
output_dir (str): Directory to output the input files.
**kwargs: kwargs supported by LammpsData.write_file.
"""
write_lammps_inputs(
Copy link
Contributor Author

@DanielYang59 DanielYang59 Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need some LAMMPS expert to fix this, this class has only one method but deprecated (the class itself is not):

class LammpsTemplateGen(TemplateInputGen):
"""Create an InputSet object for a LAMMPS run based on a template file.
The input script is constructed by substituting variables into placeholders
in the template file using python's Template.safe_substitute() function.
The data file containing coordinates and topology information can be provided
as a LammpsData instance. Alternatively, you can include a read_data command
in the template file that points to an existing data file.
Other supporting files are not handled at the moment.
To write the input files to a directory, call LammpsTemplateSet.write_input()
See pymatgen.io.template.py for additional documentation of this method.
"""
def get_input_set(

output_dir=output_dir,
script_template=self.script_template,
settings=self.settings,
data=self.data,
script_filename=self.script_filename,
**kwargs,
)
# TODO: write_lammps_inputs is deprecated
with warnings.catch_warnings():
warnings.filterwarnings("ignore", message="write_lammps_inputs is deprecated")

write_lammps_inputs(
output_dir=output_dir,
script_template=self.script_template,
settings=self.settings,
data=self.data,
script_filename=self.script_filename,
**kwargs,
)

@classmethod
def md(
Expand Down
5 changes: 2 additions & 3 deletions src/pymatgen/io/lammps/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ def from_dict(cls, dct: dict) -> Self:
Returns:
LammpsDump
"""
items = {"timestep": dct["timestep"], "natoms": dct["natoms"]}
items["box"] = LammpsBox.from_dict(dct["box"])
items["data"] = pd.read_json(dct["data"], orient="split")
items = {"timestep": dct["timestep"], "natoms": dct["natoms"], "box": LammpsBox.from_dict(dct["box"])}
items["data"] = pd.read_json(StringIO(dct["data"]), orient="split")
return cls(**items)

def as_dict(self) -> dict[str, Any]:
Expand Down
8 changes: 4 additions & 4 deletions src/pymatgen/io/lobster/lobsterenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,16 @@ def __init__(
if valences_from_charges and filename_charge is not None:
chg = Charge(filename=filename_charge)
if which_charge == "Mulliken":
self.valences = chg.Mulliken
self.valences = chg.mulliken
elif which_charge == "Loewdin":
self.valences = chg.Loewdin
self.valences = chg.loewdin

elif valences_from_charges and obj_charge is not None:
chg = obj_charge
if which_charge == "Mulliken":
self.valences = chg.Mulliken
self.valences = chg.mulliken
elif which_charge == "Loewdin":
self.valences = chg.Loewdin
self.valences = chg.loewdin

else:
bv_analyzer = BVAnalyzer()
Expand Down
2 changes: 1 addition & 1 deletion src/pymatgen/io/lobster/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ def _read(self, lines: list[str], spin_numbers: list[int]) -> None:
_lines.append(float(el))
overlaps.append(_lines)
if len(overlaps) == len(_lines):
self.band_overlaps_dict[spin]["matrices"].append(np.matrix(overlaps))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JaGeo would appreciate it if you could have a look at this as well, got:

  /Users/yang/developer/pymatgen/src/pymatgen/io/lobster/outputs.py:1680: PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
    self.band_overlaps_dict[spin]["matrices"].append(np.matrix(overlaps))

And as per the manual:

‘array’ or ‘matrix’? Which should I use?

Historically, NumPy has provided a special matrix type, np.matrix, which is a subclass of ndarray which makes binary operations linear algebra operations. You may see it used in some existing code instead of np.array. So, which one to use?

Short answer
Use arrays.

self.band_overlaps_dict[spin]["matrices"].append(np.array(overlaps))

def has_good_quality_maxDeviation(self, limit_maxDeviation: float = 0.1) -> bool:
"""Check if the maxDeviation from the ideal bandoverlap is smaller
Expand Down
4 changes: 2 additions & 2 deletions src/pymatgen/io/openff.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def mol_graph_from_openff_mol(molecule: tk.Molecule) -> MoleculeGraph:
Returns:
MoleculeGraph: The converted MoleculeGraph.
"""
mol_graph = MoleculeGraph.with_empty_graph(Molecule([], []), name="none")
mol_graph = MoleculeGraph.from_empty_graph(Molecule([], []), name="none")
p_table = {el.Z: str(el) for el in Element}
total_charge = cum_atoms = 0

Expand Down Expand Up @@ -173,7 +173,7 @@ def infer_openff_mol(
Returns:
tk.Molecule: The inferred OpenFF Molecule.
"""
mol_graph = MoleculeGraph.with_local_env_strategy(mol_geometry, OpenBabelNN())
mol_graph = MoleculeGraph.from_local_env_strategy(mol_geometry, OpenBabelNN())
mol_graph = metal_edge_extender(mol_graph)
return mol_graph_to_openff_mol(mol_graph)

Expand Down
18 changes: 9 additions & 9 deletions src/pymatgen/io/phonopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,17 @@ def get_displaced_structures(pmg_structure, atom_disp=0.01, supercell_matrix=Non
)

if yaml_fname is not None:
displacements = phonon.get_displacements()
displacements = phonon.displacements
write_disp_yaml(
displacements=displacements,
supercell=phonon.get_supercell(),
supercell=phonon.supercell,
filename=yaml_fname,
)

# Supercell structures with displacement
disp_supercells = phonon.get_supercells_with_displacements()
disp_supercells = phonon.supercells_with_displacements
# Perfect supercell structure
init_supercell = phonon.get_supercell()
init_supercell = phonon.supercell
# Structure list to be returned
structure_list = [get_pmg_structure(init_supercell)]

Expand Down Expand Up @@ -313,7 +313,7 @@ def get_phonon_dos_from_fc(
"""
structure_phonopy = get_phonopy_structure(structure)
phonon = Phonopy(structure_phonopy, supercell_matrix=supercell_matrix, **kwargs)
phonon.set_force_constants(force_constants)
phonon.force_constants = force_constants
phonon.run_mesh(
mesh_density,
is_mesh_symmetry=False,
Expand All @@ -329,7 +329,7 @@ def get_phonon_dos_from_fc(

phonon.run_projected_dos(freq_min=freq_min, freq_max=freq_max, freq_pitch=freq_pitch)

dos_raw = phonon.projected_dos.get_partial_dos()
dos_raw = (phonon.projected_dos.frequency_points, phonon.projected_dos.projected_dos)
DanielYang59 marked this conversation as resolved.
Show resolved Hide resolved
p_doses = dict(zip(structure, dos_raw[1], strict=True))

total_dos = PhononDos(dos_raw[0], dos_raw[1].sum(axis=0))
Expand Down Expand Up @@ -360,7 +360,7 @@ def get_phonon_band_structure_from_fc(
"""
structure_phonopy = get_phonopy_structure(structure)
phonon = Phonopy(structure_phonopy, supercell_matrix=supercell_matrix, **kwargs)
phonon.set_force_constants(force_constants)
phonon.force_constants = force_constants
phonon.run_mesh(mesh_density, is_mesh_symmetry=False, is_gamma_center=True)
mesh = phonon.get_mesh_dict()

Expand Down Expand Up @@ -394,14 +394,14 @@ def get_phonon_band_structure_symm_line_from_fc(
"""
structure_phonopy = get_phonopy_structure(structure)
phonon = Phonopy(structure_phonopy, supercell_matrix=supercell_matrix, symprec=symprec, **kwargs)
phonon.set_force_constants(force_constants)
phonon.force_constants = force_constants

k_path = HighSymmKpath(structure, symprec=symprec)

kpoints, labels = k_path.get_kpoints(line_density=line_density, coords_are_cartesian=False)

phonon.run_qpoints(kpoints)
frequencies = phonon.qpoints.get_frequencies().T
frequencies = phonon.qpoints.frequencies.T

labels_dict = {a: k for a, k in zip(labels, kpoints, strict=True) if a != ""}

Expand Down
2 changes: 1 addition & 1 deletion src/pymatgen/io/vasp/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ def _parse_structure(self, elem: XML_Element) -> Structure:
@staticmethod
def _parse_diel(elem: XML_Element) -> tuple[list, list, list]:
"""Parse dielectric properties."""
if elem.find("real") and elem.find("imag"):
if elem.find("real") is not None and elem.find("imag") is not None:
DanielYang59 marked this conversation as resolved.
Show resolved Hide resolved
imag = [
[_vasprun_float(line) for line in r.text.split()] # type: ignore[union-attr]
for r in elem.find("imag").find("array").find("set").findall("r") # type: ignore[union-attr]
Expand Down
4 changes: 2 additions & 2 deletions src/pymatgen/io/vasp/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2676,7 +2676,7 @@ def incar_updates(self) -> dict[str, Any]:
updates = {
"ALGO": "Fast",
"ISIF": 3,
"LANGEVIN_GAMMA": [10] * self.structure.ntypesp,
"LANGEVIN_GAMMA": [10] * self.structure.n_elems,
"LANGEVIN_GAMMA_L": 1,
"MDALGO": 3,
"PMASS": 10,
Expand Down Expand Up @@ -2707,7 +2707,7 @@ def incar_updates(self) -> dict[str, Any]:
"LDAU": False,
}
# Set NPT-AIMD ENCUT = 1.5 * VASP_default
enmax = [self.potcar[i].keywords["ENMAX"] for i in range(self.structure.ntypesp)]
DanielYang59 marked this conversation as resolved.
Show resolved Hide resolved
enmax = [self.potcar[i].keywords["ENMAX"] for i in range(self.structure.n_elems)]
updates["ENCUT"] = max(enmax) * 1.5
return updates

Expand Down
6 changes: 5 additions & 1 deletion src/pymatgen/symmetry/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ def _get_symmetry(self) -> tuple[NDArray, NDArray]:
"translations" gives the numpy float64 array of the translation
vectors in scaled positions.
"""
dct = spglib.get_symmetry(self._cell, symprec=self._symprec, angle_tolerance=self._angle_tol)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this we get:

tests/analysis/chemenv/connectivity/test_structure_connectivity.py::TestStructureConnectivity::test_serialization
  /Users/yang/developer/pymatgen/venv312/lib/python3.12/site-packages/spglib/spglib.py:640: DeprecationWarning: Use get_magnetic_symmetry() for cell with magnetic moments.
    warnings.warn(

But this doesn't look like a in place replace, for:

dct = spglib.get_magnetic_symmetry(self._cell, symprec=self._symprec, angle_tolerance=self._angle_tol)

I got 6 test failure:


tests/symmetry/test_analyzer.py ..F....FF.F..........F.F..........                                                                             [100%]

====================================================================== FAILURES ======================================================================
__________________________________________ TestSpacegroupAnalyzer.test_get_conventional_standard_structure ___________________________________________

with warnings.catch_warnings():
# TODO: DeprecationWarning: Use get_magnetic_symmetry() for cell with magnetic moments.
warnings.filterwarnings("ignore", message="Use get_magnetic_symmetry", category=DeprecationWarning)
dct = spglib.get_symmetry(self._cell, symprec=self._symprec, angle_tolerance=self._angle_tol)

if dct is None:
symprec = self._symprec
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion src/pymatgen/transformations/advanced_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
from pymatgen.analysis.bond_valence import BVAnalyzer
from pymatgen.analysis.energy_models import SymmetryModel
from pymatgen.analysis.ewald import EwaldSummation
from pymatgen.analysis.gb.grain import GrainBoundaryGenerator
from pymatgen.analysis.local_env import MinimumDistanceNN
from pymatgen.analysis.structure_matcher import SpinComparator, StructureMatcher
from pymatgen.analysis.structure_prediction.substitution_probability import SubstitutionPredictor
from pymatgen.command_line.enumlib_caller import EnumError, EnumlibAdaptor
from pymatgen.command_line.mcsqs_caller import run_mcsqs
from pymatgen.core import DummySpecies, Element, Species, Structure, get_el_sp
from pymatgen.core.interface import GrainBoundaryGenerator
from pymatgen.core.surface import SlabGenerator
from pymatgen.electronic_structure.core import Spin
from pymatgen.io.ase import AseAtomsAdaptor
Expand Down
4 changes: 4 additions & 0 deletions tests/analysis/elasticity/test_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,10 @@ def test_get_diff_coeff(self):
backward_26,
[137 / 180, -27 / 5, 33 / 2, -254 / 9, 117 / 4, -87 / 5, 203 / 45],
)
# TODO: scipy.misc.central_diff_weights is deprecated in SciPy v1.10.0;
# and will be completely removed in SciPy v1.12.0.
# You may consider using findiff: https://github.com/maroba/findiff
# or numdifftools: https://github.com/pbrod/numdifftools
assert_allclose(central_29, central_diff_weights(9, 2))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

central_diff_weights should have been removed (but for some reason not yet), and the replacement is another package, comment this out for now?


def test_generate_pseudo(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/analysis/test_piezo_sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def test_rand_fcm(self):
structure = get_phonopy_structure(self.piezo_struct)
pn_struct = Phonopy(structure, np.eye(3), np.eye(3))

pn_struct.set_force_constants(rand_FCM)
pn_struct.force_constants = rand_FCM
dyn = pn_struct.get_dynamical_matrix_at_q([0, 0, 0])
dyn = np.reshape(dyn, (10, 3, 10, 3)).swapaxes(1, 2)
dyn = np.real(dyn)
Expand Down Expand Up @@ -296,7 +296,7 @@ def test_rand_piezo(self):
structure = get_phonopy_structure(self.piezo_struct)
pn_struct = Phonopy(structure, np.eye(3), np.eye(3))

pn_struct.set_force_constants(rand_FCM)
pn_struct.force_constants = rand_FCM
dyn = pn_struct.get_dynamical_matrix_at_q([0, 0, 0])
dyn = np.reshape(dyn, (10, 3, 10, 3)).swapaxes(1, 2)
dyn = np.real(dyn)
Expand Down
2 changes: 2 additions & 0 deletions tests/command_line/test_bader_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def test_bader_analysis_from_path(self):
assert summary["reference_used"]
assert sum(summary["magmom"]) == approx(28, abs=1e-1)

@pytest.mark.filterwarnings("ignore:_parse_atomic_densities is deprecated")
def test_atom_parsing(self):
"""TODO: Deprecated, remove after 2025-2-26, see PR3652."""
# test with reference file
analysis = BaderAnalysis(
chgcar_filename=f"{VASP_OUT_DIR}/CHGCAR.Fe3O4.gz",
Expand Down
6 changes: 6 additions & 0 deletions tests/entries/test_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
PMG_ENTRIES_DIR = os.path.dirname(os.path.abspath(pymatgen.entries.__file__))


@pytest.mark.filterwarnings("ignore:MaterialsProjectCompatibility is deprecated")
class TestCorrectionSpecificity(TestCase):
"""Make sure corrections are only applied to GGA or GGA+U entries."""

Expand Down Expand Up @@ -202,6 +203,7 @@ def test_overlapping_adjustments():
assert len(processed) == 0


@pytest.mark.filterwarnings("ignore:MaterialsProjectCompatibility is deprecated")
class TestMaterialsProjectCompatibility(TestCase):
def setUp(self):
self.entry1 = ComputedEntry(
Expand Down Expand Up @@ -592,6 +594,9 @@ def test_process_entries(self):
assert len(entries) == 2

def test_parallel_process_entries(self):
# TODO: DeprecationWarning: This process (pid=xxxx) is multi-threaded,
# use of fork() may lead to deadlocks in the child.
# pid = os.fork()
with pytest.raises(
ValueError,
match="Parallel processing is not possible with for 'inplace=True'",
Expand Down Expand Up @@ -1132,6 +1137,7 @@ def test_element_processing(self):
assert entry.energy == approx(-1)
assert self.gga_compat.process_entry(entry).energy == approx(-1)

@pytest.mark.filterwarnings("ignore:MaterialsProjectCompatibility is deprecated")
def test_get_explanation_dict(self):
compat = MaterialsProjectCompatibility(check_potcar_hash=False)
entry = ComputedEntry(
Expand Down
Loading