diff --git a/dev_scripts/chemenv/explicit_permutations.py b/dev_scripts/chemenv/explicit_permutations.py index 097e80b25e0..f3225fa5293 100644 --- a/dev_scripts/chemenv/explicit_permutations.py +++ b/dev_scripts/chemenv/explicit_permutations.py @@ -10,6 +10,7 @@ import os import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import ( AllCoordinationGeometries, ExplicitPermutationsAlgorithm, diff --git a/dev_scripts/chemenv/explicit_permutations_plane_algorithm.py b/dev_scripts/chemenv/explicit_permutations_plane_algorithm.py index 689ae58d86a..bd71080c300 100644 --- a/dev_scripts/chemenv/explicit_permutations_plane_algorithm.py +++ b/dev_scripts/chemenv/explicit_permutations_plane_algorithm.py @@ -9,6 +9,7 @@ import json import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import AllCoordinationGeometries from pymatgen.analysis.chemenv.coordination_environments.coordination_geometry_finder import ( AbstractGeometry, diff --git a/dev_scripts/chemenv/get_plane_permutations_optimized.py b/dev_scripts/chemenv/get_plane_permutations_optimized.py index 127ca009f19..1244d13e487 100644 --- a/dev_scripts/chemenv/get_plane_permutations_optimized.py +++ b/dev_scripts/chemenv/get_plane_permutations_optimized.py @@ -15,6 +15,7 @@ import numpy as np import tabulate + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import AllCoordinationGeometries from pymatgen.analysis.chemenv.coordination_environments.coordination_geometry_finder import ( AbstractGeometry, diff --git a/dev_scripts/chemenv/strategies/multi_weights_strategy_parameters.py b/dev_scripts/chemenv/strategies/multi_weights_strategy_parameters.py index 70449d924f8..495a8bb668e 100644 --- a/dev_scripts/chemenv/strategies/multi_weights_strategy_parameters.py +++ b/dev_scripts/chemenv/strategies/multi_weights_strategy_parameters.py @@ -8,6 +8,7 @@ import matplotlib.pyplot as plt import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies import ( AngleNbSetWeight, CNBiasNbSetWeight, diff --git a/dev_scripts/chemenv/test_algos.py b/dev_scripts/chemenv/test_algos.py index 17933a067a3..dbffdce27e5 100644 --- a/dev_scripts/chemenv/test_algos.py +++ b/dev_scripts/chemenv/test_algos.py @@ -8,6 +8,7 @@ from random import shuffle import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import AllCoordinationGeometries from pymatgen.analysis.chemenv.coordination_environments.coordination_geometry_finder import ( AbstractGeometry, diff --git a/dev_scripts/chemenv/view_environment.py b/dev_scripts/chemenv/view_environment.py index 69aa6adc42e..2caa22e9f34 100644 --- a/dev_scripts/chemenv/view_environment.py +++ b/dev_scripts/chemenv/view_environment.py @@ -3,6 +3,7 @@ from __future__ import annotations import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import ( SEPARATION_PLANE, AllCoordinationGeometries, diff --git a/dev_scripts/potcar_scrambler.py b/dev_scripts/potcar_scrambler.py index c0793c713d9..0dd2b0190fa 100644 --- a/dev_scripts/potcar_scrambler.py +++ b/dev_scripts/potcar_scrambler.py @@ -9,6 +9,7 @@ import numpy as np from monty.os.path import zpath from monty.serialization import zopen + from pymatgen.core import SETTINGS from pymatgen.io.vasp import Potcar, PotcarSingle from pymatgen.io.vasp.sets import _load_yaml_config diff --git a/dev_scripts/update_pt_data.py b/dev_scripts/update_pt_data.py index ee7889c75ea..88f321ed712 100644 --- a/dev_scripts/update_pt_data.py +++ b/dev_scripts/update_pt_data.py @@ -11,9 +11,10 @@ import requests from monty.dev import requires from monty.serialization import dumpfn, loadfn -from pymatgen.core import Element, get_el_sp from ruamel import yaml +from pymatgen.core import Element, get_el_sp + try: from bs4 import BeautifulSoup except ImportError: diff --git a/dev_scripts/update_spacegroup_data.py b/dev_scripts/update_spacegroup_data.py index a4607cdbee7..b0f1c348ab9 100644 --- a/dev_scripts/update_spacegroup_data.py +++ b/dev_scripts/update_spacegroup_data.py @@ -12,6 +12,7 @@ import sys from monty.serialization import dumpfn, loadfn + from pymatgen.symmetry.groups import PointGroup __author__ = "Katharina Ueltzen @kaueltzen" diff --git a/pymatgen/core/tests/test_structure.py b/pymatgen/core/tests/test_structure.py index 48e0711093b..f1f20c307c3 100644 --- a/pymatgen/core/tests/test_structure.py +++ b/pymatgen/core/tests/test_structure.py @@ -644,11 +644,11 @@ def test_get_all_neighbors_small_cutoff(self): ) all_nn = s.get_all_neighbors(1e-5, True) assert len(all_nn) == len(s) - assert [] == all_nn[0] + assert all_nn[0] == [] all_nn = s.get_all_neighbors(0, True) assert len(all_nn) == len(s) - assert [] == all_nn[0] + assert all_nn[0] == [] def test_coincide_sites(self): s = Structure( diff --git a/src/pymatgen/alchemy/filters.py b/src/pymatgen/alchemy/filters.py index c16c05bf634..d133c0289e3 100644 --- a/src/pymatgen/alchemy/filters.py +++ b/src/pymatgen/alchemy/filters.py @@ -7,14 +7,16 @@ from typing import TYPE_CHECKING from monty.json import MSONable + from pymatgen.analysis.structure_matcher import ElementComparator, StructureMatcher from pymatgen.core import get_el_sp from pymatgen.symmetry.analyzer import SpacegroupAnalyzer if TYPE_CHECKING: - from pymatgen.core import Structure from typing_extensions import Self + from pymatgen.core import Structure + class AbstractStructureFilter(MSONable, abc.ABC): """Structures that return True when passed to the test() method are retained during diff --git a/src/pymatgen/alchemy/materials.py b/src/pymatgen/alchemy/materials.py index 701133215e3..2fa8b754721 100644 --- a/src/pymatgen/alchemy/materials.py +++ b/src/pymatgen/alchemy/materials.py @@ -12,6 +12,7 @@ from warnings import warn from monty.json import MSONable, jsanitize + from pymatgen.core.structure import Structure from pymatgen.io.cif import CifParser from pymatgen.io.vasp.inputs import Poscar @@ -23,9 +24,10 @@ from collections.abc import Sequence from typing import Any - from pymatgen.alchemy.filters import AbstractStructureFilter from typing_extensions import Self + from pymatgen.alchemy.filters import AbstractStructureFilter + class TransformedStructure(MSONable): """Container for new structures that include history of transformations. diff --git a/src/pymatgen/alchemy/transmuters.py b/src/pymatgen/alchemy/transmuters.py index d51ea47c247..802716520fc 100644 --- a/src/pymatgen/alchemy/transmuters.py +++ b/src/pymatgen/alchemy/transmuters.py @@ -21,9 +21,10 @@ from collections.abc import Sequence from typing import Callable - from pymatgen.alchemy.filters import AbstractStructureFilter from typing_extensions import Self + from pymatgen.alchemy.filters import AbstractStructureFilter + __author__ = "Shyue Ping Ong, Will Richards" __copyright__ = "Copyright 2012, The Materials Project" __version__ = "0.1" diff --git a/src/pymatgen/analysis/adsorption.py b/src/pymatgen/analysis/adsorption.py index 88f9f98dc3e..5fe6b7a3742 100644 --- a/src/pymatgen/analysis/adsorption.py +++ b/src/pymatgen/analysis/adsorption.py @@ -12,6 +12,8 @@ from matplotlib import patches from matplotlib.path import Path from monty.serialization import loadfn +from scipy.spatial import Delaunay + from pymatgen import vis from pymatgen.analysis.local_env import VoronoiNN from pymatgen.analysis.structure_matcher import StructureMatcher @@ -20,14 +22,14 @@ from pymatgen.core.surface import generate_all_slabs from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.coord import in_coord_list_pbc -from scipy.spatial import Delaunay if TYPE_CHECKING: import matplotlib.pyplot as plt from numpy.typing import ArrayLike - from pymatgen.core.surface import Slab from typing_extensions import Self + from pymatgen.core.surface import Slab + __author__ = "Joseph Montoya" __copyright__ = "Copyright 2016, The Materials Project" __version__ = "0.1" diff --git a/src/pymatgen/analysis/bond_dissociation.py b/src/pymatgen/analysis/bond_dissociation.py index cbf6ed83845..73b9f2d4fe2 100644 --- a/src/pymatgen/analysis/bond_dissociation.py +++ b/src/pymatgen/analysis/bond_dissociation.py @@ -8,6 +8,7 @@ import networkx as nx from monty.json import MSONable + from pymatgen.analysis.fragmenter import open_ring from pymatgen.analysis.graphs import MoleculeGraph, MolGraphSplitError from pymatgen.analysis.local_env import OpenBabelNN diff --git a/src/pymatgen/analysis/bond_valence.py b/src/pymatgen/analysis/bond_valence.py index a81a71f5462..e9cbe1fc47b 100644 --- a/src/pymatgen/analysis/bond_valence.py +++ b/src/pymatgen/analysis/bond_valence.py @@ -11,6 +11,7 @@ import numpy as np from monty.serialization import loadfn + from pymatgen.core import Element, Species, get_el_sp from pymatgen.symmetry.analyzer import SpacegroupAnalyzer diff --git a/src/pymatgen/analysis/chemenv/connectivity/connected_components.py b/src/pymatgen/analysis/chemenv/connectivity/connected_components.py index a7b361eda31..3e75f758bc8 100644 --- a/src/pymatgen/analysis/chemenv/connectivity/connected_components.py +++ b/src/pymatgen/analysis/chemenv/connectivity/connected_components.py @@ -13,6 +13,7 @@ from monty.json import MSONable, jsanitize from networkx.algorithms.components import is_connected from networkx.algorithms.traversal import bfs_tree + from pymatgen.analysis.chemenv.connectivity.environment_nodes import EnvironmentNode from pymatgen.analysis.chemenv.utils.chemenv_errors import ChemenvError from pymatgen.analysis.chemenv.utils.graph_utils import get_delta diff --git a/src/pymatgen/analysis/chemenv/connectivity/connectivity_finder.py b/src/pymatgen/analysis/chemenv/connectivity/connectivity_finder.py index 26495f4a437..99cb354f89c 100644 --- a/src/pymatgen/analysis/chemenv/connectivity/connectivity_finder.py +++ b/src/pymatgen/analysis/chemenv/connectivity/connectivity_finder.py @@ -5,6 +5,7 @@ import logging import numpy as np + from pymatgen.analysis.chemenv.connectivity.structure_connectivity import StructureConnectivity __author__ = "David Waroquiers" diff --git a/src/pymatgen/analysis/chemenv/connectivity/structure_connectivity.py b/src/pymatgen/analysis/chemenv/connectivity/structure_connectivity.py index 4fb4c54cc50..7258be9baf4 100644 --- a/src/pymatgen/analysis/chemenv/connectivity/structure_connectivity.py +++ b/src/pymatgen/analysis/chemenv/connectivity/structure_connectivity.py @@ -9,6 +9,7 @@ import networkx as nx import numpy as np from monty.json import MSONable, jsanitize + from pymatgen.analysis.chemenv.connectivity.connected_components import ConnectedComponent from pymatgen.analysis.chemenv.connectivity.environment_nodes import get_environment_node from pymatgen.analysis.chemenv.coordination_environments.structure_environments import LightStructureEnvironments diff --git a/src/pymatgen/analysis/chemenv/coordination_environments/chemenv_strategies.py b/src/pymatgen/analysis/chemenv/coordination_environments/chemenv_strategies.py index abc7c2b4778..3f814ac3ade 100644 --- a/src/pymatgen/analysis/chemenv/coordination_environments/chemenv_strategies.py +++ b/src/pymatgen/analysis/chemenv/coordination_environments/chemenv_strategies.py @@ -13,6 +13,8 @@ import numpy as np from monty.json import MSONable +from scipy.stats import gmean + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import AllCoordinationGeometries from pymatgen.analysis.chemenv.coordination_environments.voronoi import DetailedVoronoiContainer from pymatgen.analysis.chemenv.utils.chemenv_errors import EquivalentSiteSearchError @@ -27,7 +29,6 @@ from pymatgen.core.operations import SymmOp from pymatgen.core.sites import PeriodicSite from pymatgen.symmetry.analyzer import SpacegroupAnalyzer -from scipy.stats import gmean if TYPE_CHECKING: from typing import ClassVar diff --git a/src/pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py b/src/pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py index 523448b5bde..2e2b91e0066 100644 --- a/src/pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py +++ b/src/pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py @@ -23,6 +23,7 @@ import numpy as np from numpy.linalg import norm, svd + from pymatgen.analysis.bond_valence import BVAnalyzer from pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies import MultiWeightsChemenvStrategy from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import ( diff --git a/src/pymatgen/analysis/chemenv/coordination_environments/structure_environments.py b/src/pymatgen/analysis/chemenv/coordination_environments/structure_environments.py index 5b81229ced8..5d03166f83f 100644 --- a/src/pymatgen/analysis/chemenv/coordination_environments/structure_environments.py +++ b/src/pymatgen/analysis/chemenv/coordination_environments/structure_environments.py @@ -17,6 +17,7 @@ from matplotlib.gridspec import GridSpec from matplotlib.patches import Polygon from monty.json import MontyDecoder, MSONable, jsanitize + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import AllCoordinationGeometries from pymatgen.analysis.chemenv.coordination_environments.voronoi import DetailedVoronoiContainer from pymatgen.analysis.chemenv.utils.chemenv_errors import ChemenvError diff --git a/src/pymatgen/analysis/chemenv/coordination_environments/voronoi.py b/src/pymatgen/analysis/chemenv/coordination_environments/voronoi.py index 08f257d3ae2..77fc1ffcbd4 100644 --- a/src/pymatgen/analysis/chemenv/coordination_environments/voronoi.py +++ b/src/pymatgen/analysis/chemenv/coordination_environments/voronoi.py @@ -9,6 +9,8 @@ import matplotlib.pyplot as plt import numpy as np from monty.json import MSONable +from scipy.spatial import Voronoi + from pymatgen.analysis.chemenv.utils.coordination_geometry_utils import ( get_lower_and_upper_f, rectangle_surface_intersection, @@ -18,7 +20,6 @@ from pymatgen.analysis.chemenv.utils.math_utils import normal_cdf_step from pymatgen.core.sites import PeriodicSite from pymatgen.core.structure import Structure -from scipy.spatial import Voronoi if TYPE_CHECKING: from typing_extensions import Self diff --git a/src/pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py b/src/pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py index 358d03d39a0..edf391b023b 100644 --- a/src/pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py +++ b/src/pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py @@ -7,11 +7,12 @@ import numpy as np from numpy.linalg import norm -from pymatgen.analysis.chemenv.utils.chemenv_errors import SolidAngleError from scipy.integrate import quad from scipy.interpolate import UnivariateSpline from scipy.spatial import ConvexHull +from pymatgen.analysis.chemenv.utils.chemenv_errors import SolidAngleError + if TYPE_CHECKING: from typing import Callable diff --git a/src/pymatgen/analysis/chemenv/utils/func_utils.py b/src/pymatgen/analysis/chemenv/utils/func_utils.py index d8437cde208..5bae04c94a9 100644 --- a/src/pymatgen/analysis/chemenv/utils/func_utils.py +++ b/src/pymatgen/analysis/chemenv/utils/func_utils.py @@ -5,6 +5,7 @@ from typing import TYPE_CHECKING import numpy as np + from pymatgen.analysis.chemenv.utils.math_utils import ( power2_decreasing_exp, power2_inverse_decreasing, diff --git a/src/pymatgen/analysis/chemenv/utils/scripts_utils.py b/src/pymatgen/analysis/chemenv/utils/scripts_utils.py index e153a7fcb63..ca0fe90c08c 100644 --- a/src/pymatgen/analysis/chemenv/utils/scripts_utils.py +++ b/src/pymatgen/analysis/chemenv/utils/scripts_utils.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies import ( SimpleAbundanceChemenvStrategy, SimplestChemenvStrategy, diff --git a/src/pymatgen/analysis/chempot_diagram.py b/src/pymatgen/analysis/chempot_diagram.py index 769c3a69b8f..a2c6cfc7031 100644 --- a/src/pymatgen/analysis/chempot_diagram.py +++ b/src/pymatgen/analysis/chempot_diagram.py @@ -33,12 +33,13 @@ import plotly.express as px from monty.json import MSONable from plotly.graph_objects import Figure, Mesh3d, Scatter, Scatter3d +from scipy.spatial import ConvexHull, HalfspaceIntersection + from pymatgen.analysis.phase_diagram import PDEntry, PhaseDiagram from pymatgen.core.composition import Composition, Element from pymatgen.util.coord import Simplex from pymatgen.util.due import Doi, due from pymatgen.util.string import htmlify -from scipy.spatial import ConvexHull, HalfspaceIntersection if TYPE_CHECKING: from pymatgen.entries.computed_entries import ComputedEntry diff --git a/src/pymatgen/analysis/cost.py b/src/pymatgen/analysis/cost.py index 8ed4689301c..458fea711e6 100644 --- a/src/pymatgen/analysis/cost.py +++ b/src/pymatgen/analysis/cost.py @@ -17,6 +17,7 @@ import scipy.constants as const from monty.design_patterns import singleton + from pymatgen.analysis.phase_diagram import PDEntry, PhaseDiagram from pymatgen.core import Composition, Element from pymatgen.util.provenance import is_valid_bibtex diff --git a/src/pymatgen/analysis/diffraction/core.py b/src/pymatgen/analysis/diffraction/core.py index 4a4dce2623a..4e852b5e8f8 100644 --- a/src/pymatgen/analysis/diffraction/core.py +++ b/src/pymatgen/analysis/diffraction/core.py @@ -8,6 +8,7 @@ import matplotlib.pyplot as plt import numpy as np + from pymatgen.core.spectrum import Spectrum from pymatgen.util.plotting import add_fig_kwargs, pretty_plot diff --git a/src/pymatgen/analysis/diffraction/neutron.py b/src/pymatgen/analysis/diffraction/neutron.py index d9ef7328935..59d36759ba0 100644 --- a/src/pymatgen/analysis/diffraction/neutron.py +++ b/src/pymatgen/analysis/diffraction/neutron.py @@ -8,6 +8,7 @@ from typing import TYPE_CHECKING import numpy as np + from pymatgen.analysis.diffraction.core import ( AbstractDiffractionPatternCalculator, DiffractionPattern, diff --git a/src/pymatgen/analysis/diffraction/tem.py b/src/pymatgen/analysis/diffraction/tem.py index 98103a22945..45b8b9f9cf4 100644 --- a/src/pymatgen/analysis/diffraction/tem.py +++ b/src/pymatgen/analysis/diffraction/tem.py @@ -11,6 +11,7 @@ import pandas as pd import plotly.graph_objects as go import scipy.constants as sc + from pymatgen.analysis.diffraction.core import AbstractDiffractionPatternCalculator from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.string import latexify_spacegroup, unicodeify_spacegroup @@ -18,6 +19,7 @@ if TYPE_CHECKING: from numpy.typing import NDArray + from pymatgen.core import Structure __author__ = "Frank Wan, Jason Liang" diff --git a/src/pymatgen/analysis/diffraction/xrd.py b/src/pymatgen/analysis/diffraction/xrd.py index 654cab6d3fe..49eb07e05a0 100644 --- a/src/pymatgen/analysis/diffraction/xrd.py +++ b/src/pymatgen/analysis/diffraction/xrd.py @@ -8,6 +8,7 @@ from typing import TYPE_CHECKING import numpy as np + from pymatgen.analysis.diffraction.core import ( AbstractDiffractionPatternCalculator, DiffractionPattern, diff --git a/src/pymatgen/analysis/dimensionality.py b/src/pymatgen/analysis/dimensionality.py index 93746d4f5db..7ce19444e03 100644 --- a/src/pymatgen/analysis/dimensionality.py +++ b/src/pymatgen/analysis/dimensionality.py @@ -29,6 +29,7 @@ import networkx as nx import numpy as np from networkx.readwrite import json_graph + from pymatgen.analysis.graphs import MoleculeGraph, StructureGraph from pymatgen.analysis.local_env import JmolNN from pymatgen.analysis.structure_analyzer import get_max_bond_lengths diff --git a/src/pymatgen/analysis/elasticity/elastic.py b/src/pymatgen/analysis/elasticity/elastic.py index 805b6017013..7ac2ef19015 100644 --- a/src/pymatgen/analysis/elasticity/elastic.py +++ b/src/pymatgen/analysis/elasticity/elastic.py @@ -13,23 +13,25 @@ import numpy as np import sympy as sp +from scipy.integrate import quad +from scipy.optimize import root +from scipy.special import factorial + from pymatgen.analysis.elasticity.strain import Strain from pymatgen.analysis.elasticity.stress import Stress from pymatgen.core.tensors import DEFAULT_QUAD, SquareTensor, Tensor, TensorCollection, get_uvec from pymatgen.core.units import Unit from pymatgen.util.due import Doi, due -from scipy.integrate import quad -from scipy.optimize import root -from scipy.special import factorial if TYPE_CHECKING: from collections.abc import Sequence from typing import Literal from numpy.typing import ArrayLike - from pymatgen.core import Structure from typing_extensions import Self + from pymatgen.core import Structure + __author__ = "Joseph Montoya" __copyright__ = "Copyright 2012, The Materials Project" diff --git a/src/pymatgen/analysis/elasticity/strain.py b/src/pymatgen/analysis/elasticity/strain.py index 13092b5daf2..99fe716a249 100644 --- a/src/pymatgen/analysis/elasticity/strain.py +++ b/src/pymatgen/analysis/elasticity/strain.py @@ -12,6 +12,7 @@ import numpy as np import scipy + from pymatgen.core.lattice import Lattice from pymatgen.core.tensors import SquareTensor, symmetry_reduce @@ -20,9 +21,10 @@ from typing import Literal from numpy.typing import ArrayLike - from pymatgen.core.structure import Structure from typing_extensions import Self + from pymatgen.core.structure import Structure + __author__ = "Joseph Montoya" __copyright__ = "Copyright 2012, The Materials Project" __credits__ = "Maarten de Jong, Mark Asta, Anubhav Jain" diff --git a/src/pymatgen/analysis/elasticity/stress.py b/src/pymatgen/analysis/elasticity/stress.py index 720eb00dc4f..3e5765130ca 100644 --- a/src/pymatgen/analysis/elasticity/stress.py +++ b/src/pymatgen/analysis/elasticity/stress.py @@ -9,6 +9,7 @@ from typing import TYPE_CHECKING import numpy as np + from pymatgen.core.tensors import SquareTensor if TYPE_CHECKING: diff --git a/src/pymatgen/analysis/energy_models.py b/src/pymatgen/analysis/energy_models.py index 501287f7f01..fa3c6a1d091 100644 --- a/src/pymatgen/analysis/energy_models.py +++ b/src/pymatgen/analysis/energy_models.py @@ -10,13 +10,15 @@ from typing import TYPE_CHECKING from monty.json import MSONable + from pymatgen.analysis.ewald import EwaldSummation from pymatgen.symmetry.analyzer import SpacegroupAnalyzer if TYPE_CHECKING: - from pymatgen.core import Structure from typing_extensions import Self + from pymatgen.core import Structure + __version__ = "0.1" diff --git a/src/pymatgen/analysis/eos.py b/src/pymatgen/analysis/eos.py index fc526884537..b5f49e472fa 100644 --- a/src/pymatgen/analysis/eos.py +++ b/src/pymatgen/analysis/eos.py @@ -13,9 +13,10 @@ from typing import TYPE_CHECKING import numpy as np +from scipy.optimize import leastsq, minimize + from pymatgen.core.units import FloatWithUnit from pymatgen.util.plotting import add_fig_kwargs, get_ax_fig, pretty_plot -from scipy.optimize import leastsq, minimize if TYPE_CHECKING: from typing import ClassVar diff --git a/src/pymatgen/analysis/ewald.py b/src/pymatgen/analysis/ewald.py index 46fb6c523ee..e37d6a4c793 100644 --- a/src/pymatgen/analysis/ewald.py +++ b/src/pymatgen/analysis/ewald.py @@ -11,11 +11,12 @@ import numpy as np from monty.json import MSONable -from pymatgen.core.structure import Structure -from pymatgen.util.due import Doi, due from scipy import constants from scipy.special import comb, erfc +from pymatgen.core.structure import Structure +from pymatgen.util.due import Doi, due + if TYPE_CHECKING: from typing import Any diff --git a/src/pymatgen/analysis/ferroelectricity/polarization.py b/src/pymatgen/analysis/ferroelectricity/polarization.py index 2e0175fdf3b..0ec0e7e1043 100644 --- a/src/pymatgen/analysis/ferroelectricity/polarization.py +++ b/src/pymatgen/analysis/ferroelectricity/polarization.py @@ -48,16 +48,18 @@ from typing import TYPE_CHECKING import numpy as np +from scipy.interpolate import UnivariateSpline + from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure -from scipy.interpolate import UnivariateSpline if TYPE_CHECKING: from collections.abc import Sequence - from pymatgen.core.sites import PeriodicSite from typing_extensions import Self + from pymatgen.core.sites import PeriodicSite + __author__ = "Tess Smidt" __copyright__ = "Copyright 2017, The Materials Project" diff --git a/src/pymatgen/analysis/fragmenter.py b/src/pymatgen/analysis/fragmenter.py index 98ad92a2b24..7458a46dfeb 100644 --- a/src/pymatgen/analysis/fragmenter.py +++ b/src/pymatgen/analysis/fragmenter.py @@ -7,6 +7,7 @@ from typing import TYPE_CHECKING from monty.json import MSONable + from pymatgen.analysis.graphs import MoleculeGraph, MolGraphSplitError from pymatgen.analysis.local_env import OpenBabelNN, metal_edge_extender from pymatgen.io.babel import BabelMolAdaptor diff --git a/src/pymatgen/analysis/graphs.py b/src/pymatgen/analysis/graphs.py index 998db8a72bf..9a206c5e578 100644 --- a/src/pymatgen/analysis/graphs.py +++ b/src/pymatgen/analysis/graphs.py @@ -20,12 +20,13 @@ from monty.json import MSONable from networkx.drawing.nx_agraph import write_dot from networkx.readwrite import json_graph +from scipy.spatial import KDTree +from scipy.stats import describe + from pymatgen.core import Lattice, Molecule, PeriodicSite, Structure from pymatgen.core.structure import FunctionalGroups from pymatgen.util.coord import lattice_points_in_supercell from pymatgen.vis.structure_vtk import EL_COLORS -from scipy.spatial import KDTree -from scipy.stats import describe try: import igraph @@ -38,10 +39,11 @@ from igraph import Graph from numpy.typing import ArrayLike + from typing_extensions import Self + from pymatgen.analysis.local_env import NearNeighbors from pymatgen.core import Species from pymatgen.util.typing import Tuple3Ints - from typing_extensions import Self logger = logging.getLogger(__name__) diff --git a/src/pymatgen/analysis/hhi.py b/src/pymatgen/analysis/hhi.py index b893fe3a131..85708e78366 100644 --- a/src/pymatgen/analysis/hhi.py +++ b/src/pymatgen/analysis/hhi.py @@ -14,6 +14,7 @@ import os from monty.design_patterns import singleton + from pymatgen.core import Composition, Element __author__ = "Anubhav Jain" diff --git a/src/pymatgen/analysis/interface_reactions.py b/src/pymatgen/analysis/interface_reactions.py index 908cd538ff0..9c89adbc8b1 100644 --- a/src/pymatgen/analysis/interface_reactions.py +++ b/src/pymatgen/analysis/interface_reactions.py @@ -15,6 +15,7 @@ from monty.json import MSONable from pandas import DataFrame from plotly.graph_objects import Figure, Scatter + from pymatgen.analysis.phase_diagram import GrandPotentialPhaseDiagram, PhaseDiagram from pymatgen.analysis.reaction_calculator import Reaction from pymatgen.core.composition import Composition diff --git a/src/pymatgen/analysis/interfaces/coherent_interfaces.py b/src/pymatgen/analysis/interfaces/coherent_interfaces.py index e52dab38e04..3e145fc5618 100644 --- a/src/pymatgen/analysis/interfaces/coherent_interfaces.py +++ b/src/pymatgen/analysis/interfaces/coherent_interfaces.py @@ -7,11 +7,12 @@ import numpy as np from numpy.testing import assert_allclose +from scipy.linalg import polar + from pymatgen.analysis.elasticity.strain import Deformation from pymatgen.analysis.interfaces.zsl import ZSLGenerator, fast_norm from pymatgen.core.interface import Interface, label_termination from pymatgen.core.surface import SlabGenerator -from scipy.linalg import polar if TYPE_CHECKING: from collections.abc import Iterator, Sequence diff --git a/src/pymatgen/analysis/interfaces/substrate_analyzer.py b/src/pymatgen/analysis/interfaces/substrate_analyzer.py index 62b2a4a5152..41746fdd24d 100644 --- a/src/pymatgen/analysis/interfaces/substrate_analyzer.py +++ b/src/pymatgen/analysis/interfaces/substrate_analyzer.py @@ -11,9 +11,10 @@ if TYPE_CHECKING: from numpy.typing import ArrayLike + from typing_extensions import Self + from pymatgen.core import Structure from pymatgen.util.typing import Tuple3Ints - from typing_extensions import Self @dataclass diff --git a/src/pymatgen/analysis/interfaces/zsl.py b/src/pymatgen/analysis/interfaces/zsl.py index fdd17dbcdb0..8aae62a46c1 100644 --- a/src/pymatgen/analysis/interfaces/zsl.py +++ b/src/pymatgen/analysis/interfaces/zsl.py @@ -8,6 +8,7 @@ import numpy as np from monty.json import MSONable + from pymatgen.util.due import Doi, due from pymatgen.util.numba import njit diff --git a/src/pymatgen/analysis/local_env.py b/src/pymatgen/analysis/local_env.py index d4acd5a7d2f..3a4c7d68ea7 100644 --- a/src/pymatgen/analysis/local_env.py +++ b/src/pymatgen/analysis/local_env.py @@ -19,12 +19,13 @@ import numpy as np from monty.dev import deprecated, requires from monty.serialization import loadfn +from ruamel.yaml import YAML +from scipy.spatial import Voronoi + from pymatgen.analysis.bond_valence import BV_PARAMS, BVAnalyzer from pymatgen.analysis.graphs import MoleculeGraph, StructureGraph from pymatgen.analysis.molecule_structure_comparator import CovalentRadius from pymatgen.core import Element, IStructure, PeriodicNeighbor, PeriodicSite, Site, Species, Structure -from ruamel.yaml import YAML -from scipy.spatial import Voronoi try: from openbabel import openbabel @@ -34,9 +35,10 @@ if TYPE_CHECKING: from typing import Any + from typing_extensions import Self + from pymatgen.core.composition import SpeciesLike from pymatgen.util.typing import Tuple3Ints - from typing_extensions import Self __author__ = "Shyue Ping Ong, Geoffroy Hautier, Sai Jayaraman, " diff --git a/src/pymatgen/analysis/magnetism/analyzer.py b/src/pymatgen/analysis/magnetism/analyzer.py index 59359e773fd..6c10495630b 100644 --- a/src/pymatgen/analysis/magnetism/analyzer.py +++ b/src/pymatgen/analysis/magnetism/analyzer.py @@ -13,6 +13,10 @@ import numpy as np from monty.serialization import loadfn +from ruamel.yaml.error import MarkedYAMLError +from scipy.signal import argrelextrema +from scipy.stats import gaussian_kde + from pymatgen.core.structure import DummySpecies, Element, Species, Structure from pymatgen.electronic_structure.core import Magmom from pymatgen.symmetry.analyzer import SpacegroupAnalyzer @@ -20,9 +24,6 @@ from pymatgen.transformations.advanced_transformations import MagOrderingTransformation, MagOrderParameterConstraint from pymatgen.transformations.standard_transformations import AutoOxiStateDecorationTransformation from pymatgen.util.due import Doi, due -from ruamel.yaml.error import MarkedYAMLError -from scipy.signal import argrelextrema -from scipy.stats import gaussian_kde if TYPE_CHECKING: from typing import Any diff --git a/src/pymatgen/analysis/magnetism/heisenberg.py b/src/pymatgen/analysis/magnetism/heisenberg.py index ac627f903b1..35f4c12f116 100644 --- a/src/pymatgen/analysis/magnetism/heisenberg.py +++ b/src/pymatgen/analysis/magnetism/heisenberg.py @@ -15,6 +15,7 @@ import pandas as pd from monty.json import MSONable, jsanitize from monty.serialization import dumpfn + from pymatgen.analysis.graphs import StructureGraph from pymatgen.analysis.local_env import MinimumDistanceNN from pymatgen.analysis.magnetism import CollinearMagneticStructureAnalyzer, Ordering diff --git a/src/pymatgen/analysis/magnetism/jahnteller.py b/src/pymatgen/analysis/magnetism/jahnteller.py index 90727f19e15..dda2d3b4907 100644 --- a/src/pymatgen/analysis/magnetism/jahnteller.py +++ b/src/pymatgen/analysis/magnetism/jahnteller.py @@ -7,6 +7,7 @@ from typing import TYPE_CHECKING, Literal, cast import numpy as np + from pymatgen.analysis.bond_valence import BVAnalyzer from pymatgen.analysis.local_env import LocalStructOrderParams, get_neighbors_of_site_with_index from pymatgen.core import Species, get_el_sp diff --git a/src/pymatgen/analysis/molecule_matcher.py b/src/pymatgen/analysis/molecule_matcher.py index 1b779e6898c..a8da516d5a5 100644 --- a/src/pymatgen/analysis/molecule_matcher.py +++ b/src/pymatgen/analysis/molecule_matcher.py @@ -22,12 +22,14 @@ import numpy as np from monty.dev import requires from monty.json import MSONable -from pymatgen.core.structure import Molecule from scipy.optimize import linear_sum_assignment from scipy.spatial.distance import cdist +from pymatgen.core.structure import Molecule + try: from openbabel import openbabel + from pymatgen.io.babel import BabelMolAdaptor except ImportError: openbabel = BabelMolAdaptor = None # type: ignore[misc] diff --git a/src/pymatgen/analysis/molecule_structure_comparator.py b/src/pymatgen/analysis/molecule_structure_comparator.py index 28400b65a34..32d603abd28 100644 --- a/src/pymatgen/analysis/molecule_structure_comparator.py +++ b/src/pymatgen/analysis/molecule_structure_comparator.py @@ -14,6 +14,7 @@ from typing import TYPE_CHECKING from monty.json import MSONable + from pymatgen.util.due import Doi, due if TYPE_CHECKING: diff --git a/src/pymatgen/analysis/nmr.py b/src/pymatgen/analysis/nmr.py index 91a7ccd21d4..bf16031f028 100644 --- a/src/pymatgen/analysis/nmr.py +++ b/src/pymatgen/analysis/nmr.py @@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, NamedTuple import numpy as np + from pymatgen.core import Site, Species from pymatgen.core.tensors import SquareTensor from pymatgen.core.units import FloatWithUnit diff --git a/src/pymatgen/analysis/phase_diagram.py b/src/pymatgen/analysis/phase_diagram.py index 6369e2369a0..e8222f3c507 100644 --- a/src/pymatgen/analysis/phase_diagram.py +++ b/src/pymatgen/analysis/phase_diagram.py @@ -21,6 +21,11 @@ from matplotlib.colors import LinearSegmentedColormap, Normalize from matplotlib.font_manager import FontProperties from monty.json import MontyDecoder, MSONable +from scipy import interpolate +from scipy.optimize import minimize +from scipy.spatial import ConvexHull +from tqdm import tqdm + from pymatgen.analysis.reaction_calculator import Reaction, ReactionError from pymatgen.core import DummySpecies, Element, get_el_sp from pymatgen.core.composition import Composition @@ -29,10 +34,6 @@ from pymatgen.util.due import Doi, due from pymatgen.util.plotting import pretty_plot from pymatgen.util.string import htmlify, latexify -from scipy import interpolate -from scipy.optimize import minimize -from scipy.spatial import ConvexHull -from tqdm import tqdm if TYPE_CHECKING: from collections.abc import Collection, Iterator, Sequence diff --git a/src/pymatgen/analysis/piezo.py b/src/pymatgen/analysis/piezo.py index 7a5b32ac8d0..2f168e1eef4 100644 --- a/src/pymatgen/analysis/piezo.py +++ b/src/pymatgen/analysis/piezo.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING import numpy as np + from pymatgen.core.tensors import Tensor if TYPE_CHECKING: diff --git a/src/pymatgen/analysis/piezo_sensitivity.py b/src/pymatgen/analysis/piezo_sensitivity.py index d5b4f232199..0a93140dc15 100644 --- a/src/pymatgen/analysis/piezo_sensitivity.py +++ b/src/pymatgen/analysis/piezo_sensitivity.py @@ -7,6 +7,7 @@ import numpy as np from monty.dev import requires + from pymatgen.core.tensors import Tensor from pymatgen.symmetry.analyzer import SpacegroupAnalyzer diff --git a/src/pymatgen/analysis/pourbaix_diagram.py b/src/pymatgen/analysis/pourbaix_diagram.py index dad540db5fb..74fa89f3d22 100644 --- a/src/pymatgen/analysis/pourbaix_diagram.py +++ b/src/pymatgen/analysis/pourbaix_diagram.py @@ -16,6 +16,9 @@ import numpy as np from monty.json import MontyDecoder, MSONable +from scipy.spatial import ConvexHull, HalfspaceIntersection +from scipy.special import comb + from pymatgen.analysis.phase_diagram import PDEntry, PhaseDiagram from pymatgen.analysis.reaction_calculator import Reaction, ReactionError from pymatgen.core import Composition, Element @@ -26,8 +29,6 @@ from pymatgen.util.due import Doi, due from pymatgen.util.plotting import pretty_plot from pymatgen.util.string import Stringify -from scipy.spatial import ConvexHull, HalfspaceIntersection -from scipy.special import comb if TYPE_CHECKING: from typing import Any diff --git a/src/pymatgen/analysis/prototypes.py b/src/pymatgen/analysis/prototypes.py index 6423e53170c..a9cdf29c70c 100644 --- a/src/pymatgen/analysis/prototypes.py +++ b/src/pymatgen/analysis/prototypes.py @@ -17,6 +17,7 @@ from typing import TYPE_CHECKING from monty.serialization import loadfn + from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.util.due import Doi, due diff --git a/src/pymatgen/analysis/quasiharmonic.py b/src/pymatgen/analysis/quasiharmonic.py index f7b8aa08a05..d1c7612fecf 100644 --- a/src/pymatgen/analysis/quasiharmonic.py +++ b/src/pymatgen/analysis/quasiharmonic.py @@ -15,14 +15,15 @@ import numpy as np from monty.dev import deprecated -from pymatgen.analysis.eos import EOS, PolynomialEOS -from pymatgen.core.units import FloatWithUnit -from pymatgen.util.due import Doi, due from scipy.constants import physical_constants from scipy.integrate import quadrature from scipy.misc import derivative from scipy.optimize import minimize +from pymatgen.analysis.eos import EOS, PolynomialEOS +from pymatgen.core.units import FloatWithUnit +from pymatgen.util.due import Doi, due + __author__ = "Kiran Mathew, Brandon Bocklund" __credits__ = "Cormac Toher" diff --git a/src/pymatgen/analysis/quasirrho.py b/src/pymatgen/analysis/quasirrho.py index 5846f19339b..0c66f730db3 100644 --- a/src/pymatgen/analysis/quasirrho.py +++ b/src/pymatgen/analysis/quasirrho.py @@ -15,14 +15,16 @@ import numpy as np import scipy.constants as const + from pymatgen.core.units import kb as kb_ev from pymatgen.util.due import Doi, due if TYPE_CHECKING: + from typing_extensions import Self + from pymatgen.core import Molecule from pymatgen.io.gaussian import GaussianOutput from pymatgen.io.qchem.outputs import QCOutput - from typing_extensions import Self __author__ = "Alex Epstein" __copyright__ = "Copyright 2020, The Materials Project" diff --git a/src/pymatgen/analysis/reaction_calculator.py b/src/pymatgen/analysis/reaction_calculator.py index 638e9189318..456e6ea97d9 100644 --- a/src/pymatgen/analysis/reaction_calculator.py +++ b/src/pymatgen/analysis/reaction_calculator.py @@ -10,16 +10,18 @@ import numpy as np from monty.fractions import gcd_float from monty.json import MontyDecoder, MSONable +from uncertainties import ufloat + from pymatgen.core.composition import Composition from pymatgen.entries.computed_entries import ComputedEntry -from uncertainties import ufloat if TYPE_CHECKING: from collections.abc import Mapping + from typing_extensions import Self + from pymatgen.core import Element, Species from pymatgen.util.typing import CompositionLike - from typing_extensions import Self __author__ = "Shyue Ping Ong, Anubhav Jain" __copyright__ = "Copyright 2011, The Materials Project" diff --git a/src/pymatgen/analysis/solar/slme.py b/src/pymatgen/analysis/solar/slme.py index 976ef49b701..cc7fdf2dabf 100644 --- a/src/pymatgen/analysis/solar/slme.py +++ b/src/pymatgen/analysis/solar/slme.py @@ -22,9 +22,10 @@ from scipy.integrate import simpson except ImportError: from scipy.integrate import simps as simpson +from scipy.interpolate import interp1d + from pymatgen.io.vasp.outputs import Vasprun from pymatgen.util.due import Doi, due -from scipy.interpolate import interp1d due.cite( Doi("10.1021/acs.chemmater.9b02166"), diff --git a/src/pymatgen/analysis/structure_analyzer.py b/src/pymatgen/analysis/structure_analyzer.py index a044216444a..45bc60da98d 100644 --- a/src/pymatgen/analysis/structure_analyzer.py +++ b/src/pymatgen/analysis/structure_analyzer.py @@ -10,10 +10,11 @@ import matplotlib.pyplot as plt import numpy as np +from scipy.spatial import Voronoi + from pymatgen.analysis.local_env import JmolNN, VoronoiNN from pymatgen.core import Composition, Element, PeriodicSite, Species from pymatgen.symmetry.analyzer import SpacegroupAnalyzer -from scipy.spatial import Voronoi if TYPE_CHECKING: from pymatgen.core import Structure diff --git a/src/pymatgen/analysis/structure_matcher.py b/src/pymatgen/analysis/structure_matcher.py index 7a2650bef71..0ad9c9db788 100644 --- a/src/pymatgen/analysis/structure_matcher.py +++ b/src/pymatgen/analysis/structure_matcher.py @@ -8,6 +8,7 @@ import numpy as np from monty.json import MSONable + from pymatgen.core import Composition, Lattice, Structure, get_el_sp from pymatgen.optimization.linear_assignment import LinearAssignment from pymatgen.util.coord import lattice_points_in_supercell @@ -17,9 +18,10 @@ from collections.abc import Mapping, Sequence from typing import Literal - from pymatgen.util.typing import SpeciesLike from typing_extensions import Self + from pymatgen.util.typing import SpeciesLike + __author__ = "William Davidson Richards, Stephen Dacek, Shyue Ping Ong" __copyright__ = "Copyright 2011, The Materials Project" __version__ = "1.0" diff --git a/src/pymatgen/analysis/structure_prediction/dopant_predictor.py b/src/pymatgen/analysis/structure_prediction/dopant_predictor.py index dcc750ec9f3..e21603e13ee 100644 --- a/src/pymatgen/analysis/structure_prediction/dopant_predictor.py +++ b/src/pymatgen/analysis/structure_prediction/dopant_predictor.py @@ -5,6 +5,7 @@ import warnings import numpy as np + from pymatgen.analysis.structure_prediction.substitution_probability import SubstitutionPredictor from pymatgen.core import Element, Species diff --git a/src/pymatgen/analysis/structure_prediction/substitution_probability.py b/src/pymatgen/analysis/structure_prediction/substitution_probability.py index 75720ce9419..210e218d2b1 100644 --- a/src/pymatgen/analysis/structure_prediction/substitution_probability.py +++ b/src/pymatgen/analysis/structure_prediction/substitution_probability.py @@ -13,6 +13,7 @@ from typing import TYPE_CHECKING from monty.design_patterns import cached_class + from pymatgen.core import Species, get_el_sp from pymatgen.util.due import Doi, due diff --git a/src/pymatgen/analysis/structure_prediction/substitutor.py b/src/pymatgen/analysis/structure_prediction/substitutor.py index c36df98f030..2921355d637 100644 --- a/src/pymatgen/analysis/structure_prediction/substitutor.py +++ b/src/pymatgen/analysis/structure_prediction/substitutor.py @@ -9,6 +9,7 @@ from typing import TYPE_CHECKING from monty.json import MSONable + from pymatgen.alchemy.filters import RemoveDuplicatesFilter, RemoveExistingFilter from pymatgen.alchemy.materials import TransformedStructure from pymatgen.alchemy.transmuters import StandardTransmuter diff --git a/src/pymatgen/analysis/structure_prediction/volume_predictor.py b/src/pymatgen/analysis/structure_prediction/volume_predictor.py index 5ce74b652f4..dd749e8416a 100644 --- a/src/pymatgen/analysis/structure_prediction/volume_predictor.py +++ b/src/pymatgen/analysis/structure_prediction/volume_predictor.py @@ -7,6 +7,7 @@ import numpy as np from monty.serialization import loadfn + from pymatgen.analysis.bond_valence import BVAnalyzer from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core import Structure diff --git a/src/pymatgen/analysis/surface_analysis.py b/src/pymatgen/analysis/surface_analysis.py index f395f90afd0..ff49d82088f 100644 --- a/src/pymatgen/analysis/surface_analysis.py +++ b/src/pymatgen/analysis/surface_analysis.py @@ -42,6 +42,9 @@ import matplotlib.pyplot as plt import numpy as np +from sympy import Symbol +from sympy.solvers import linsolve, solve + from pymatgen.analysis.wulff import WulffShape from pymatgen.core import Structure from pymatgen.core.composition import Composition @@ -51,13 +54,12 @@ from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.due import Doi, due from pymatgen.util.plotting import pretty_plot -from sympy import Symbol -from sympy.solvers import linsolve, solve if TYPE_CHECKING: - from pymatgen.util.typing import Tuple3Ints from typing_extensions import Self + from pymatgen.util.typing import Tuple3Ints + EV_PER_ANG2_TO_JOULES_PER_M2 = 16.0217656 __author__ = "Richard Tran" diff --git a/src/pymatgen/analysis/topological/spillage.py b/src/pymatgen/analysis/topological/spillage.py index e088b98553b..d0da47ccfe1 100644 --- a/src/pymatgen/analysis/topological/spillage.py +++ b/src/pymatgen/analysis/topological/spillage.py @@ -8,6 +8,7 @@ from __future__ import annotations import numpy as np + from pymatgen.io.vasp.outputs import Wavecar diff --git a/src/pymatgen/analysis/transition_state.py b/src/pymatgen/analysis/transition_state.py index e7c6d9b2924..5dbbe1fbb54 100644 --- a/src/pymatgen/analysis/transition_state.py +++ b/src/pymatgen/analysis/transition_state.py @@ -15,11 +15,12 @@ import matplotlib.pyplot as plt import numpy as np from monty.json import MSONable, jsanitize +from scipy.interpolate import CubicSpline + from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core import Structure from pymatgen.io.vasp import Outcar from pymatgen.util.plotting import pretty_plot -from scipy.interpolate import CubicSpline if TYPE_CHECKING: from typing_extensions import Self diff --git a/src/pymatgen/analysis/wulff.py b/src/pymatgen/analysis/wulff.py index 23a6986d87f..420d77c4161 100644 --- a/src/pymatgen/analysis/wulff.py +++ b/src/pymatgen/analysis/wulff.py @@ -25,10 +25,11 @@ import matplotlib.pyplot as plt import numpy as np import plotly.graph_objects as go +from scipy.spatial import ConvexHull + from pymatgen.core.structure import Structure from pymatgen.util.coord import get_angle from pymatgen.util.string import unicodeify_spacegroup -from scipy.spatial import ConvexHull if TYPE_CHECKING: from pymatgen.core.lattice import Lattice diff --git a/src/pymatgen/analysis/xas/spectrum.py b/src/pymatgen/analysis/xas/spectrum.py index 97af8b85282..007c4596642 100644 --- a/src/pymatgen/analysis/xas/spectrum.py +++ b/src/pymatgen/analysis/xas/spectrum.py @@ -7,10 +7,11 @@ from typing import TYPE_CHECKING import numpy as np +from scipy.interpolate import interp1d + from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core.spectrum import Spectrum from pymatgen.symmetry.analyzer import SpacegroupAnalyzer -from scipy.interpolate import interp1d if TYPE_CHECKING: from typing import Literal diff --git a/src/pymatgen/analysis/xps.py b/src/pymatgen/analysis/xps.py index 4e9acff9540..1aca37a1eee 100644 --- a/src/pymatgen/analysis/xps.py +++ b/src/pymatgen/analysis/xps.py @@ -25,14 +25,16 @@ import numpy as np import pandas as pd + from pymatgen.core import Element from pymatgen.core.spectrum import Spectrum from pymatgen.util.due import Doi, due if TYPE_CHECKING: - from pymatgen.electronic_structure.dos import CompleteDos from typing_extensions import Self + from pymatgen.electronic_structure.dos import CompleteDos + due.cite( Doi("10.21105/joss.007733"), diff --git a/src/pymatgen/apps/battery/analyzer.py b/src/pymatgen/apps/battery/analyzer.py index 3d08e147c35..2543b44da92 100644 --- a/src/pymatgen/apps/battery/analyzer.py +++ b/src/pymatgen/apps/battery/analyzer.py @@ -6,6 +6,7 @@ from collections import defaultdict import scipy.constants as const + from pymatgen.core import Composition, Element, Species __author__ = "Anubhav Jain" diff --git a/src/pymatgen/apps/battery/battery_abc.py b/src/pymatgen/apps/battery/battery_abc.py index 8465f85445f..78f4d984498 100644 --- a/src/pymatgen/apps/battery/battery_abc.py +++ b/src/pymatgen/apps/battery/battery_abc.py @@ -12,9 +12,10 @@ from typing import TYPE_CHECKING from monty.json import MSONable -from pymatgen.core import Composition, Element from scipy.constants import N_A +from pymatgen.core import Composition, Element + if TYPE_CHECKING: from pymatgen.entries.computed_entries import ComputedEntry diff --git a/src/pymatgen/apps/battery/conversion_battery.py b/src/pymatgen/apps/battery/conversion_battery.py index ee274bcd40d..b84da63efd6 100644 --- a/src/pymatgen/apps/battery/conversion_battery.py +++ b/src/pymatgen/apps/battery/conversion_battery.py @@ -5,19 +5,21 @@ from dataclasses import dataclass from typing import TYPE_CHECKING +from scipy.constants import N_A + from pymatgen.analysis.phase_diagram import PhaseDiagram from pymatgen.analysis.reaction_calculator import BalancedReaction from pymatgen.apps.battery.battery_abc import AbstractElectrode, AbstractVoltagePair from pymatgen.core import Composition, Element from pymatgen.core.units import Charge, Time -from scipy.constants import N_A if TYPE_CHECKING: from collections.abc import Iterable - from pymatgen.entries.computed_entries import ComputedEntry from typing_extensions import Self + from pymatgen.entries.computed_entries import ComputedEntry + @dataclass class ConversionElectrode(AbstractElectrode): diff --git a/src/pymatgen/apps/battery/insertion_battery.py b/src/pymatgen/apps/battery/insertion_battery.py index 5f073fbc916..76631f53368 100644 --- a/src/pymatgen/apps/battery/insertion_battery.py +++ b/src/pymatgen/apps/battery/insertion_battery.py @@ -9,12 +9,13 @@ from typing import TYPE_CHECKING from monty.json import MontyDecoder +from scipy.constants import N_A + from pymatgen.analysis.phase_diagram import PDEntry, PhaseDiagram from pymatgen.apps.battery.battery_abc import AbstractElectrode, AbstractVoltagePair from pymatgen.core import Composition, Element from pymatgen.core.units import Charge, Time from pymatgen.entries.computed_entries import ComputedEntry, ComputedStructureEntry -from scipy.constants import N_A if TYPE_CHECKING: from collections.abc import Iterable diff --git a/src/pymatgen/apps/battery/plotter.py b/src/pymatgen/apps/battery/plotter.py index 150f413784b..f8725ef25e6 100644 --- a/src/pymatgen/apps/battery/plotter.py +++ b/src/pymatgen/apps/battery/plotter.py @@ -6,6 +6,7 @@ import matplotlib.pyplot as plt import plotly.graph_objects as go + from pymatgen.util.plotting import pretty_plot if TYPE_CHECKING: diff --git a/src/pymatgen/apps/borg/hive.py b/src/pymatgen/apps/borg/hive.py index 87aaeeb2500..a90380d0dee 100644 --- a/src/pymatgen/apps/borg/hive.py +++ b/src/pymatgen/apps/borg/hive.py @@ -12,6 +12,7 @@ from monty.io import zopen from monty.json import MSONable + from pymatgen.entries.computed_entries import ComputedEntry, ComputedStructureEntry from pymatgen.io.gaussian import GaussianOutput from pymatgen.io.vasp.inputs import Incar, Poscar, Potcar diff --git a/src/pymatgen/cli/feff_plot_cross_section.py b/src/pymatgen/cli/feff_plot_cross_section.py index 2bf9d89fe23..a9a59f3a650 100755 --- a/src/pymatgen/cli/feff_plot_cross_section.py +++ b/src/pymatgen/cli/feff_plot_cross_section.py @@ -7,6 +7,7 @@ import argparse import matplotlib.pyplot as plt + from pymatgen.io.feff.outputs import Xmu from pymatgen.util.plotting import pretty_plot diff --git a/src/pymatgen/cli/pmg.py b/src/pymatgen/cli/pmg.py index 1ee6a93ed7e..491d4ab2c11 100755 --- a/src/pymatgen/cli/pmg.py +++ b/src/pymatgen/cli/pmg.py @@ -7,6 +7,8 @@ import argparse import itertools +from tabulate import tabulate, tabulate_formats + from pymatgen.cli.pmg_analyze import analyze from pymatgen.cli.pmg_config import configure_pmg from pymatgen.cli.pmg_plot import plot @@ -15,7 +17,6 @@ from pymatgen.core import SETTINGS from pymatgen.core.structure import Structure from pymatgen.io.vasp import Incar, Potcar -from tabulate import tabulate, tabulate_formats def parse_view(args): diff --git a/src/pymatgen/cli/pmg_analyze.py b/src/pymatgen/cli/pmg_analyze.py index 4db3fbcb2f6..c12ef4186ef 100644 --- a/src/pymatgen/cli/pmg_analyze.py +++ b/src/pymatgen/cli/pmg_analyze.py @@ -7,10 +7,11 @@ import os import re +from tabulate import tabulate + from pymatgen.apps.borg.hive import SimpleVaspToComputedEntryDrone, VaspToComputedEntryDrone from pymatgen.apps.borg.queen import BorgQueen from pymatgen.io.vasp import Outcar -from tabulate import tabulate __author__ = "Shyue Ping Ong" __copyright__ = "Copyright 2012, The Materials Project" diff --git a/src/pymatgen/cli/pmg_config.py b/src/pymatgen/cli/pmg_config.py index 8a0f4a04317..d8253983e19 100755 --- a/src/pymatgen/cli/pmg_config.py +++ b/src/pymatgen/cli/pmg_config.py @@ -13,10 +13,11 @@ from monty.json import jsanitize from monty.serialization import dumpfn, loadfn +from ruamel import yaml + from pymatgen.core import OLD_SETTINGS_FILE, SETTINGS_FILE, Element from pymatgen.io.cp2k.inputs import GaussianTypeOrbitalBasisSet, GthPotential from pymatgen.io.cp2k.utils import chunk -from ruamel import yaml if TYPE_CHECKING: from argparse import Namespace diff --git a/src/pymatgen/cli/pmg_plot.py b/src/pymatgen/cli/pmg_plot.py index 56e7d629660..89d0fa269ae 100755 --- a/src/pymatgen/cli/pmg_plot.py +++ b/src/pymatgen/cli/pmg_plot.py @@ -5,6 +5,7 @@ from __future__ import annotations import matplotlib.pyplot as plt + from pymatgen.analysis.diffraction.xrd import XRDCalculator from pymatgen.core.structure import Structure from pymatgen.electronic_structure.plotter import DosPlotter diff --git a/src/pymatgen/cli/pmg_structure.py b/src/pymatgen/cli/pmg_structure.py index b8046b699ce..3f85040fede 100755 --- a/src/pymatgen/cli/pmg_structure.py +++ b/src/pymatgen/cli/pmg_structure.py @@ -4,10 +4,11 @@ from __future__ import annotations +from tabulate import tabulate + from pymatgen.analysis.structure_matcher import ElementComparator, StructureMatcher from pymatgen.core.structure import Structure from pymatgen.symmetry.analyzer import SpacegroupAnalyzer -from tabulate import tabulate __author__ = "Shyue Ping Ong" __copyright__ = "Copyright 2012, The Materials Project" diff --git a/src/pymatgen/command_line/bader_caller.py b/src/pymatgen/command_line/bader_caller.py index c85baf861ed..dbbb743acc9 100644 --- a/src/pymatgen/command_line/bader_caller.py +++ b/src/pymatgen/command_line/bader_caller.py @@ -27,6 +27,7 @@ from monty.dev import deprecated from monty.shutil import decompress_file from monty.tempfile import ScratchDir + from pymatgen.io.common import VolumetricData from pymatgen.io.vasp.inputs import Potcar from pymatgen.io.vasp.outputs import Chgcar @@ -34,9 +35,10 @@ if TYPE_CHECKING: from typing import Any - from pymatgen.core import Structure from typing_extensions import Self + from pymatgen.core import Structure + __author__ = "shyuepingong" __version__ = "0.1" __maintainer__ = "Shyue Ping Ong" diff --git a/src/pymatgen/command_line/chargemol_caller.py b/src/pymatgen/command_line/chargemol_caller.py index a22e4b345a0..d9b17a27404 100644 --- a/src/pymatgen/command_line/chargemol_caller.py +++ b/src/pymatgen/command_line/chargemol_caller.py @@ -51,6 +51,7 @@ import numpy as np from monty.tempfile import ScratchDir + from pymatgen.core import Element from pymatgen.io.vasp.inputs import Potcar from pymatgen.io.vasp.outputs import Chgcar diff --git a/src/pymatgen/command_line/critic2_caller.py b/src/pymatgen/command_line/critic2_caller.py index 9855345d7ff..4f6261afe3e 100644 --- a/src/pymatgen/command_line/critic2_caller.py +++ b/src/pymatgen/command_line/critic2_caller.py @@ -52,17 +52,19 @@ from monty.json import MSONable from monty.serialization import loadfn from monty.tempfile import ScratchDir +from scipy.spatial import KDTree + from pymatgen.analysis.graphs import StructureGraph from pymatgen.core import DummySpecies from pymatgen.io.vasp.inputs import Potcar from pymatgen.io.vasp.outputs import Chgcar, VolumetricData from pymatgen.util.due import Doi, due -from scipy.spatial import KDTree if TYPE_CHECKING: - from pymatgen.core import Structure from typing_extensions import Self + from pymatgen.core import Structure + logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/src/pymatgen/command_line/enumlib_caller.py b/src/pymatgen/command_line/enumlib_caller.py index 619060b8386..bdae0256e0e 100644 --- a/src/pymatgen/command_line/enumlib_caller.py +++ b/src/pymatgen/command_line/enumlib_caller.py @@ -39,6 +39,7 @@ from monty.dev import requires from monty.fractions import lcm from monty.tempfile import ScratchDir + from pymatgen.core import DummySpecies, PeriodicSite, Structure from pymatgen.io.vasp.inputs import Poscar from pymatgen.symmetry.analyzer import SpacegroupAnalyzer diff --git a/src/pymatgen/command_line/gulp_caller.py b/src/pymatgen/command_line/gulp_caller.py index fa3e250b99a..b13912f2433 100644 --- a/src/pymatgen/command_line/gulp_caller.py +++ b/src/pymatgen/command_line/gulp_caller.py @@ -10,6 +10,7 @@ import subprocess from monty.tempfile import ScratchDir + from pymatgen.analysis.bond_valence import BVAnalyzer from pymatgen.core import Element, Lattice, Structure from pymatgen.symmetry.analyzer import SpacegroupAnalyzer diff --git a/src/pymatgen/command_line/mcsqs_caller.py b/src/pymatgen/command_line/mcsqs_caller.py index 980f04e2f13..dd1cca70b1c 100644 --- a/src/pymatgen/command_line/mcsqs_caller.py +++ b/src/pymatgen/command_line/mcsqs_caller.py @@ -13,6 +13,7 @@ from typing import TYPE_CHECKING, NamedTuple from monty.dev import requires + from pymatgen.core.structure import Structure if TYPE_CHECKING: diff --git a/src/pymatgen/command_line/vampire_caller.py b/src/pymatgen/command_line/vampire_caller.py index 44aa50c3895..8709088514d 100644 --- a/src/pymatgen/command_line/vampire_caller.py +++ b/src/pymatgen/command_line/vampire_caller.py @@ -21,6 +21,7 @@ import pandas as pd from monty.dev import requires from monty.json import MSONable + from pymatgen.analysis.magnetism.heisenberg import HeisenbergMapper __author__ = "ncfrey" diff --git a/src/pymatgen/core/__init__.py b/src/pymatgen/core/__init__.py index c1f047de11c..2b160c6b793 100644 --- a/src/pymatgen/core/__init__.py +++ b/src/pymatgen/core/__init__.py @@ -7,6 +7,8 @@ from importlib.metadata import PackageNotFoundError, version from typing import Any +from ruamel.yaml import YAML + from pymatgen.core.composition import Composition from pymatgen.core.lattice import Lattice from pymatgen.core.operations import SymmOp @@ -14,7 +16,6 @@ from pymatgen.core.sites import PeriodicSite, Site from pymatgen.core.structure import IMolecule, IStructure, Molecule, PeriodicNeighbor, SiteCollection, Structure from pymatgen.core.units import ArrayWithUnit, FloatWithUnit, Unit -from ruamel.yaml import YAML __author__ = "Pymatgen Development Team" __email__ = "pymatgen@googlegroups.com" diff --git a/src/pymatgen/core/composition.py b/src/pymatgen/core/composition.py index 8eaa6a5400d..a387dafd12c 100644 --- a/src/pymatgen/core/composition.py +++ b/src/pymatgen/core/composition.py @@ -18,6 +18,7 @@ from monty.fractions import gcd, gcd_float from monty.json import MSONable from monty.serialization import loadfn + from pymatgen.core.periodic_table import DummySpecies, Element, ElementType, Species, get_el_sp from pymatgen.core.units import Mass from pymatgen.util.string import Stringify, formula_double_format @@ -26,9 +27,10 @@ from collections.abc import Generator, Iterator from typing import Any, ClassVar - from pymatgen.util.typing import SpeciesLike from typing_extensions import Self + from pymatgen.util.typing import SpeciesLike + module_dir = os.path.dirname(os.path.abspath(__file__)) diff --git a/src/pymatgen/core/interface.py b/src/pymatgen/core/interface.py index 2856130e014..0ac14fd1453 100644 --- a/src/pymatgen/core/interface.py +++ b/src/pymatgen/core/interface.py @@ -15,6 +15,9 @@ import numpy as np from monty.fractions import lcm from numpy.testing import assert_allclose +from scipy.cluster.hierarchy import fcluster, linkage +from scipy.spatial.distance import squareform + from pymatgen.analysis.adsorption import AdsorbateSiteFinder from pymatgen.core.lattice import Lattice from pymatgen.core.sites import PeriodicSite, Site @@ -22,17 +25,16 @@ from pymatgen.core.surface import Slab from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.typing import Tuple3Ints -from scipy.cluster.hierarchy import fcluster, linkage -from scipy.spatial.distance import squareform if TYPE_CHECKING: from collections.abc import Sequence from typing import Any, Callable from numpy.typing import ArrayLike, NDArray + from typing_extensions import Self + from pymatgen.core import Element from pymatgen.util.typing import CompositionLike, Matrix3D, MillerIndex, Tuple3Floats, Vector3D - from typing_extensions import Self Tuple4Ints = tuple[int, int, int, int] logger = logging.getLogger(__name__) diff --git a/src/pymatgen/core/lattice.py b/src/pymatgen/core/lattice.py index 89f28628e6d..5448c09813a 100644 --- a/src/pymatgen/core/lattice.py +++ b/src/pymatgen/core/lattice.py @@ -16,17 +16,19 @@ import numpy as np from monty.dev import deprecated from monty.json import MSONable +from scipy.spatial import Voronoi + from pymatgen.util.coord import pbc_shortest_vectors from pymatgen.util.due import Doi, due -from scipy.spatial import Voronoi if TYPE_CHECKING: from collections.abc import Iterator from numpy.typing import ArrayLike + from typing_extensions import Self + from pymatgen.core.operations import SymmOp from pymatgen.util.typing import MillerIndex, PbcLike, Vector3D - from typing_extensions import Self __author__ = "Shyue Ping Ong, Michael Kocher" __copyright__ = "Copyright 2011, The Materials Project" diff --git a/src/pymatgen/core/operations.py b/src/pymatgen/core/operations.py index c67603c288f..54f24f8515b 100644 --- a/src/pymatgen/core/operations.py +++ b/src/pymatgen/core/operations.py @@ -10,6 +10,7 @@ import numpy as np from monty.json import MSONable + from pymatgen.electronic_structure.core import Magmom from pymatgen.util.due import Doi, due from pymatgen.util.string import transformation_to_string diff --git a/src/pymatgen/core/periodic_table.py b/src/pymatgen/core/periodic_table.py index ddc31e6bb1e..3cabc1f6889 100644 --- a/src/pymatgen/core/periodic_table.py +++ b/src/pymatgen/core/periodic_table.py @@ -17,6 +17,7 @@ import numpy as np from monty.dev import deprecated from monty.json import MSONable + from pymatgen.core.units import SUPPORTED_UNIT_NAMES, FloatWithUnit, Ha_to_eV, Length, Mass, Unit from pymatgen.io.core import ParseError from pymatgen.util.string import Stringify, formula_double_format @@ -24,9 +25,10 @@ if TYPE_CHECKING: from typing import Any, Callable, Literal - from pymatgen.util.typing import SpeciesLike from typing_extensions import Self + from pymatgen.util.typing import SpeciesLike + # Load element data from JSON file with open(Path(__file__).absolute().parent / "periodic_table.json", encoding="utf-8") as ptable_json: _pt_data = json.load(ptable_json) diff --git a/src/pymatgen/core/sites.py b/src/pymatgen/core/sites.py index fd8a61118ef..a703c79a335 100644 --- a/src/pymatgen/core/sites.py +++ b/src/pymatgen/core/sites.py @@ -8,6 +8,7 @@ import numpy as np from monty.json import MontyDecoder, MontyEncoder, MSONable + from pymatgen.core.composition import Composition from pymatgen.core.lattice import Lattice from pymatgen.core.periodic_table import DummySpecies, Element, Species, get_el_sp @@ -17,9 +18,10 @@ from typing import Any from numpy.typing import ArrayLike - from pymatgen.util.typing import CompositionLike, SpeciesLike, Vector3D from typing_extensions import Self + from pymatgen.util.typing import CompositionLike, SpeciesLike, Vector3D + class Site(collections.abc.Hashable, MSONable): """A generalized *non-periodic* site. This is essentially a composition diff --git a/src/pymatgen/core/spectrum.py b/src/pymatgen/core/spectrum.py index 94ade3ce43e..6567f3a63a2 100644 --- a/src/pymatgen/core/spectrum.py +++ b/src/pymatgen/core/spectrum.py @@ -8,10 +8,11 @@ import numpy as np from monty.json import MSONable -from pymatgen.util.coord import get_linear_interpolated_value from scipy import stats from scipy.ndimage import convolve1d +from pymatgen.util.coord import get_linear_interpolated_value + if TYPE_CHECKING: from typing import Callable, Literal diff --git a/src/pymatgen/core/structure.py b/src/pymatgen/core/structure.py index f0d7d477ad6..9886d3035d0 100644 --- a/src/pymatgen/core/structure.py +++ b/src/pymatgen/core/structure.py @@ -31,6 +31,12 @@ from monty.json import MSONable from numpy import cross, eye from numpy.linalg import norm +from ruamel.yaml import YAML +from scipy.cluster.hierarchy import fcluster, linkage +from scipy.linalg import expm, polar +from scipy.spatial.distance import squareform +from tabulate import tabulate + from pymatgen.core.bonds import CovalentBond, get_bond_length from pymatgen.core.composition import Composition from pymatgen.core.lattice import Lattice, get_points_in_spheres @@ -41,11 +47,6 @@ from pymatgen.electronic_structure.core import Magmom from pymatgen.symmetry.maggroups import MagneticSpaceGroup from pymatgen.util.coord import all_distances, get_angle, lattice_points_in_supercell -from ruamel.yaml import YAML -from scipy.cluster.hierarchy import fcluster, linkage -from scipy.linalg import expm, polar -from scipy.spatial.distance import squareform -from tabulate import tabulate if TYPE_CHECKING: from collections.abc import Iterable, Iterator, Sequence @@ -58,9 +59,10 @@ from ase.optimize.optimize import Optimizer from matgl.ext.ase import TrajectoryObserver from numpy.typing import ArrayLike, NDArray - from pymatgen.util.typing import CompositionLike, MillerIndex, PathLike, PbcLike, SpeciesLike from typing_extensions import Self + from pymatgen.util.typing import CompositionLike, MillerIndex, PathLike, PbcLike, SpeciesLike + FileFormats = Literal["cif", "poscar", "cssr", "json", "yaml", "yml", "xsf", "mcsqs", "res", "pwmat", ""] StructureSources = Literal["Materials Project", "COD"] @@ -827,6 +829,7 @@ def _relax( from ase.constraints import ExpCellFilter from ase.io import read from ase.optimize.optimize import Optimizer + from pymatgen.io.ase import AseAtomsAdaptor opt_kwargs = opt_kwargs or {} diff --git a/src/pymatgen/core/surface.py b/src/pymatgen/core/surface.py index f59d3a3cbc0..7e8e969e405 100644 --- a/src/pymatgen/core/surface.py +++ b/src/pymatgen/core/surface.py @@ -27,24 +27,26 @@ import numpy as np from monty.fractions import lcm +from scipy.cluster.hierarchy import fcluster, linkage +from scipy.spatial.distance import squareform + from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core import Lattice, PeriodicSite, Structure, get_el_sp from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.coord import in_coord_list from pymatgen.util.due import Doi, due from pymatgen.util.typing import Tuple3Ints -from scipy.cluster.hierarchy import fcluster, linkage -from scipy.spatial.distance import squareform if TYPE_CHECKING: from collections.abc import Sequence from typing import Any from numpy.typing import ArrayLike, NDArray + from typing_extensions import Self + from pymatgen.core.composition import Element, Species from pymatgen.symmetry.groups import CrystalSystem from pymatgen.util.typing import MillerIndex - from typing_extensions import Self __author__ = "Richard Tran, Wenhao Sun, Zihan Xu, Shyue Ping Ong" diff --git a/src/pymatgen/core/tensors.py b/src/pymatgen/core/tensors.py index feacea08c43..cb7234cc6ed 100644 --- a/src/pymatgen/core/tensors.py +++ b/src/pymatgen/core/tensors.py @@ -15,20 +15,22 @@ import numpy as np from monty.json import MSONable from monty.serialization import loadfn +from scipy.linalg import polar + from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core.lattice import Lattice from pymatgen.core.operations import SymmOp from pymatgen.symmetry.analyzer import SpacegroupAnalyzer -from scipy.linalg import polar if TYPE_CHECKING: from collections.abc import Sequence from typing import Any from numpy.typing import NDArray - from pymatgen.core import Structure from typing_extensions import Self + from pymatgen.core import Structure + __author__ = "Joseph Montoya" __credits__ = "Maarten de Jong, Shyam Dwaraknath, Wei Chen, Mark Asta, Anubhav Jain, Terence Lew" diff --git a/src/pymatgen/core/trajectory.py b/src/pymatgen/core/trajectory.py index 1d50e2a8df5..ad595bb0e45 100644 --- a/src/pymatgen/core/trajectory.py +++ b/src/pymatgen/core/trajectory.py @@ -13,6 +13,7 @@ import numpy as np from monty.io import zopen from monty.json import MSONable + from pymatgen.core.structure import Composition, DummySpecies, Element, Lattice, Molecule, Species, Structure from pymatgen.io.ase import AseAtomsAdaptor @@ -20,9 +21,10 @@ from collections.abc import Iterator from typing import Any - from pymatgen.util.typing import Matrix3D, PathLike, SitePropsType, Vector3D from typing_extensions import Self + from pymatgen.util.typing import Matrix3D, PathLike, SitePropsType, Vector3D + __author__ = "Eric Sivonxay, Shyam Dwaraknath, Mingjian Wen, Evan Spotte-Smith" __version__ = "0.1" diff --git a/src/pymatgen/core/xcfunc.py b/src/pymatgen/core/xcfunc.py index 4b2e46d7376..a17d9c939fb 100644 --- a/src/pymatgen/core/xcfunc.py +++ b/src/pymatgen/core/xcfunc.py @@ -6,6 +6,7 @@ from monty.functools import lazy_property from monty.json import MSONable + from pymatgen.core.libxcfunc import LibxcFunc if TYPE_CHECKING: diff --git a/src/pymatgen/electronic_structure/bandstructure.py b/src/pymatgen/electronic_structure/bandstructure.py index f03160bb9ea..f844674be2b 100644 --- a/src/pymatgen/electronic_structure/bandstructure.py +++ b/src/pymatgen/electronic_structure/bandstructure.py @@ -11,6 +11,7 @@ import numpy as np from monty.json import MSONable + from pymatgen.core import Element, Lattice, Structure, get_el_sp from pymatgen.electronic_structure.core import Orbital, Spin from pymatgen.symmetry.analyzer import SpacegroupAnalyzer diff --git a/src/pymatgen/electronic_structure/boltztrap.py b/src/pymatgen/electronic_structure/boltztrap.py index 980ccb4f1a7..fe4d8ce2649 100644 --- a/src/pymatgen/electronic_structure/boltztrap.py +++ b/src/pymatgen/electronic_structure/boltztrap.py @@ -31,6 +31,10 @@ from monty.dev import requires from monty.json import MSONable, jsanitize from monty.os import cd +from scipy import constants +from scipy.optimize import fsolve +from scipy.spatial import distance + from pymatgen.core.lattice import Lattice from pymatgen.core.units import Energy, Length from pymatgen.electronic_structure.bandstructure import BandStructureSymmLine, Kpoint @@ -38,17 +42,15 @@ from pymatgen.electronic_structure.dos import CompleteDos, Dos, Spin from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.symmetry.bandstructure import HighSymmKpath -from scipy import constants -from scipy.optimize import fsolve -from scipy.spatial import distance if TYPE_CHECKING: from typing import Literal from numpy.typing import ArrayLike + from typing_extensions import Self + from pymatgen.core.sites import PeriodicSite from pymatgen.core.structure import Structure - from typing_extensions import Self __author__ = "Geoffroy Hautier, Zachary Gibbs, Francesco Ricci, Anubhav Jain" __copyright__ = "Copyright 2013, The Materials Project" diff --git a/src/pymatgen/electronic_structure/boltztrap2.py b/src/pymatgen/electronic_structure/boltztrap2.py index d84df06e2a9..d3ed99d5167 100644 --- a/src/pymatgen/electronic_structure/boltztrap2.py +++ b/src/pymatgen/electronic_structure/boltztrap2.py @@ -34,6 +34,8 @@ import matplotlib.pyplot as plt import numpy as np from monty.serialization import dumpfn, loadfn +from tqdm import tqdm + from pymatgen.electronic_structure.bandstructure import BandStructure, BandStructureSymmLine, Spin from pymatgen.electronic_structure.boltztrap import BoltztrapError from pymatgen.electronic_structure.dos import CompleteDos, Dos, Orbital @@ -41,7 +43,6 @@ from pymatgen.io.ase import AseAtomsAdaptor from pymatgen.io.vasp import Vasprun from pymatgen.symmetry.bandstructure import HighSymmKpath -from tqdm import tqdm if TYPE_CHECKING: from pathlib import Path diff --git a/src/pymatgen/electronic_structure/cohp.py b/src/pymatgen/electronic_structure/cohp.py index 17bcdce0be5..b641d2a3992 100644 --- a/src/pymatgen/electronic_structure/cohp.py +++ b/src/pymatgen/electronic_structure/cohp.py @@ -17,6 +17,8 @@ import numpy as np from monty.json import MSONable +from scipy.interpolate import InterpolatedUnivariateSpline + from pymatgen.core.sites import PeriodicSite from pymatgen.core.structure import Structure from pymatgen.electronic_structure.core import Orbital, Spin @@ -25,7 +27,6 @@ from pymatgen.util.coord import get_linear_interpolated_value from pymatgen.util.due import Doi, due from pymatgen.util.num import round_to_sigfigs -from scipy.interpolate import InterpolatedUnivariateSpline if TYPE_CHECKING: from typing import Any diff --git a/src/pymatgen/electronic_structure/core.py b/src/pymatgen/electronic_structure/core.py index 1297c8495aa..c10ee208137 100644 --- a/src/pymatgen/electronic_structure/core.py +++ b/src/pymatgen/electronic_structure/core.py @@ -13,9 +13,10 @@ if TYPE_CHECKING: from collections.abc import Sequence - from pymatgen.core import Lattice from typing_extensions import Self + from pymatgen.core import Lattice + @unique class Spin(Enum): diff --git a/src/pymatgen/electronic_structure/dos.py b/src/pymatgen/electronic_structure/dos.py index 26662562e7c..43605e08ade 100644 --- a/src/pymatgen/electronic_structure/dos.py +++ b/src/pymatgen/electronic_structure/dos.py @@ -8,21 +8,23 @@ import numpy as np from monty.json import MSONable +from scipy.constants import value as _cd +from scipy.ndimage import gaussian_filter1d +from scipy.signal import hilbert + from pymatgen.core import Structure, get_el_sp from pymatgen.core.spectrum import Spectrum from pymatgen.electronic_structure.core import Orbital, OrbitalType, Spin from pymatgen.util.coord import get_linear_interpolated_value -from scipy.constants import value as _cd -from scipy.ndimage import gaussian_filter1d -from scipy.signal import hilbert if TYPE_CHECKING: from collections.abc import Mapping from numpy.typing import ArrayLike, NDArray + from typing_extensions import Self + from pymatgen.core.sites import PeriodicSite from pymatgen.util.typing import SpeciesLike, Tuple3Floats - from typing_extensions import Self class DOS(Spectrum): diff --git a/src/pymatgen/electronic_structure/plotter.py b/src/pymatgen/electronic_structure/plotter.py index b11a7c264ad..f4cfa52be78 100644 --- a/src/pymatgen/electronic_structure/plotter.py +++ b/src/pymatgen/electronic_structure/plotter.py @@ -20,6 +20,7 @@ from matplotlib.gridspec import GridSpec from monty.dev import requires from monty.json import jsanitize + from pymatgen.core import Element from pymatgen.electronic_structure.bandstructure import BandStructureSymmLine from pymatgen.electronic_structure.boltztrap import BoltztrapError @@ -36,6 +37,7 @@ from typing import Literal from numpy.typing import ArrayLike + from pymatgen.electronic_structure.dos import CompleteDos, Dos logger = logging.getLogger(__name__) diff --git a/src/pymatgen/entries/__init__.py b/src/pymatgen/entries/__init__.py index fd0471b8416..51e6d6cee5a 100644 --- a/src/pymatgen/entries/__init__.py +++ b/src/pymatgen/entries/__init__.py @@ -12,6 +12,7 @@ import numpy as np from monty.json import MSONable + from pymatgen.core.composition import Composition if TYPE_CHECKING: diff --git a/src/pymatgen/entries/compatibility.py b/src/pymatgen/entries/compatibility.py index ba2ef68dd07..8108b788b7b 100644 --- a/src/pymatgen/entries/compatibility.py +++ b/src/pymatgen/entries/compatibility.py @@ -15,6 +15,9 @@ from monty.design_patterns import cached_class from monty.json import MSONable from monty.serialization import loadfn +from tqdm import tqdm +from uncertainties import ufloat + from pymatgen.analysis.structure_analyzer import oxide_type, sulfide_type from pymatgen.core import SETTINGS, Composition, Element from pymatgen.entries.computed_entries import ( @@ -27,8 +30,6 @@ ) from pymatgen.io.vasp.sets import MITRelaxSet, MPRelaxSet, VaspInputSet from pymatgen.util.due import Doi, due -from tqdm import tqdm -from uncertainties import ufloat if TYPE_CHECKING: from collections.abc import Sequence diff --git a/src/pymatgen/entries/computed_entries.py b/src/pymatgen/entries/computed_entries.py index b80a45f8b29..d17eb36bbe6 100644 --- a/src/pymatgen/entries/computed_entries.py +++ b/src/pymatgen/entries/computed_entries.py @@ -17,18 +17,20 @@ import numpy as np from monty.json import MontyDecoder, MontyEncoder, MSONable +from scipy.interpolate import interp1d +from uncertainties import ufloat + from pymatgen.core.composition import Composition from pymatgen.entries import Entry from pymatgen.util.due import Doi, due -from scipy.interpolate import interp1d -from uncertainties import ufloat if TYPE_CHECKING: from typing import Literal - from pymatgen.core import Structure from typing_extensions import Self + from pymatgen.core import Structure + __author__ = "Ryan Kingsbury, Matt McDermott, Shyue Ping Ong, Anubhav Jain" __copyright__ = "Copyright 2011-2020, The Materials Project" __version__ = "1.1" diff --git a/src/pymatgen/entries/correction_calculator.py b/src/pymatgen/entries/correction_calculator.py index 778c3885752..e832a0576c0 100644 --- a/src/pymatgen/entries/correction_calculator.py +++ b/src/pymatgen/entries/correction_calculator.py @@ -10,11 +10,12 @@ import numpy as np import plotly.graph_objects as go from monty.serialization import loadfn +from ruamel import yaml +from scipy.optimize import curve_fit + from pymatgen.analysis.reaction_calculator import ComputedReaction from pymatgen.analysis.structure_analyzer import sulfide_type from pymatgen.core import Composition, Element -from ruamel import yaml -from scipy.optimize import curve_fit class CorrectionCalculator: diff --git a/src/pymatgen/entries/entry_tools.py b/src/pymatgen/entries/entry_tools.py index fc6eb821891..6fe98612ca5 100644 --- a/src/pymatgen/entries/entry_tools.py +++ b/src/pymatgen/entries/entry_tools.py @@ -16,6 +16,7 @@ from typing import TYPE_CHECKING from monty.json import MontyDecoder, MontyEncoder, MSONable + from pymatgen.analysis.phase_diagram import PDEntry from pymatgen.analysis.structure_matcher import SpeciesComparator, StructureMatcher from pymatgen.core import Composition, Element @@ -24,9 +25,10 @@ from collections.abc import Iterable from typing import Literal + from typing_extensions import Self + from pymatgen.entries import Entry from pymatgen.entries.computed_entries import ComputedEntry, ComputedStructureEntry - from typing_extensions import Self logger = logging.getLogger(__name__) diff --git a/src/pymatgen/entries/exp_entries.py b/src/pymatgen/entries/exp_entries.py index 78adad7a6ef..e012ed7a9fb 100644 --- a/src/pymatgen/entries/exp_entries.py +++ b/src/pymatgen/entries/exp_entries.py @@ -5,6 +5,7 @@ from typing import TYPE_CHECKING from monty.json import MSONable + from pymatgen.analysis.phase_diagram import PDEntry from pymatgen.analysis.thermochemistry import ThermoData from pymatgen.core.composition import Composition diff --git a/src/pymatgen/entries/mixing_scheme.py b/src/pymatgen/entries/mixing_scheme.py index 8a4a50fb214..8f8fb637ab5 100644 --- a/src/pymatgen/entries/mixing_scheme.py +++ b/src/pymatgen/entries/mixing_scheme.py @@ -11,6 +11,7 @@ import numpy as np import pandas as pd + from pymatgen.analysis.phase_diagram import PhaseDiagram from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.entries.compatibility import ( diff --git a/src/pymatgen/ext/cod.py b/src/pymatgen/ext/cod.py index 0bc9966c2dc..21983b6891f 100644 --- a/src/pymatgen/ext/cod.py +++ b/src/pymatgen/ext/cod.py @@ -34,6 +34,7 @@ import requests from monty.dev import requires + from pymatgen.core.composition import Composition from pymatgen.core.structure import Structure diff --git a/src/pymatgen/ext/matproj.py b/src/pymatgen/ext/matproj.py index 71a4cff7a7a..a7c4318a440 100644 --- a/src/pymatgen/ext/matproj.py +++ b/src/pymatgen/ext/matproj.py @@ -20,6 +20,7 @@ import requests from monty.json import MontyDecoder + from pymatgen.core import SETTINGS from pymatgen.core import __version__ as PMG_VERSION from pymatgen.symmetry.analyzer import SpacegroupAnalyzer @@ -28,10 +29,11 @@ from typing import Callable from mp_api.client import MPRester as _MPResterNew + from typing_extensions import Self + from pymatgen.core.structure import Structure from pymatgen.entries.computed_entries import ComputedStructureEntry from pymatgen.ext.matproj_legacy import _MPResterLegacy - from typing_extensions import Self logger = logging.getLogger(__name__) diff --git a/src/pymatgen/ext/matproj_legacy.py b/src/pymatgen/ext/matproj_legacy.py index ff3ea075ec3..26b28e3ed42 100644 --- a/src/pymatgen/ext/matproj_legacy.py +++ b/src/pymatgen/ext/matproj_legacy.py @@ -20,6 +20,9 @@ import requests from monty.json import MontyDecoder, MontyEncoder +from ruamel.yaml import YAML +from tqdm import tqdm + from pymatgen.core import SETTINGS, Composition, Element, Structure from pymatgen.core import __version__ as PMG_VERSION from pymatgen.core.surface import get_symmetrically_equivalent_miller_indices @@ -28,16 +31,15 @@ from pymatgen.entries.exp_entries import ExpEntry from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.due import Doi, due -from ruamel.yaml import YAML -from tqdm import tqdm if TYPE_CHECKING: from collections.abc import Sequence from typing import Any, Literal + from typing_extensions import Self + from pymatgen.phonon.bandstructure import PhononBandStructureSymmLine from pymatgen.phonon.dos import CompletePhononDos - from typing_extensions import Self logger = logging.getLogger(__name__) MP_LOG_FILE = os.path.join(os.path.expanduser("~"), ".mprester.log.yaml") diff --git a/src/pymatgen/ext/optimade.py b/src/pymatgen/ext/optimade.py index fa7e9fb3d3c..2f5c1345429 100644 --- a/src/pymatgen/ext/optimade.py +++ b/src/pymatgen/ext/optimade.py @@ -8,10 +8,11 @@ from urllib.parse import urljoin, urlparse import requests +from tqdm import tqdm + from pymatgen.core import DummySpecies, Structure from pymatgen.util.due import Doi, due from pymatgen.util.provenance import StructureNL -from tqdm import tqdm if TYPE_CHECKING: from typing import ClassVar diff --git a/src/pymatgen/io/abinit/abiobjects.py b/src/pymatgen/io/abinit/abiobjects.py index 46482f44b3a..2057f79543f 100644 --- a/src/pymatgen/io/abinit/abiobjects.py +++ b/src/pymatgen/io/abinit/abiobjects.py @@ -13,6 +13,7 @@ from monty.collections import AttrDict from monty.design_patterns import singleton from monty.json import MontyDecoder, MontyEncoder, MSONable + from pymatgen.core import ArrayWithUnit, Lattice, Species, Structure, units if TYPE_CHECKING: diff --git a/src/pymatgen/io/abinit/abitimer.py b/src/pymatgen/io/abinit/abitimer.py index ceb86f03207..036d8ef1911 100644 --- a/src/pymatgen/io/abinit/abitimer.py +++ b/src/pymatgen/io/abinit/abitimer.py @@ -14,6 +14,7 @@ import numpy as np import pandas as pd from matplotlib.gridspec import GridSpec + from pymatgen.io.core import ParseError from pymatgen.util.plotting import add_fig_kwargs, get_ax_fig diff --git a/src/pymatgen/io/abinit/inputs.py b/src/pymatgen/io/abinit/inputs.py index 1382f819d7a..180fabff915 100644 --- a/src/pymatgen/io/abinit/inputs.py +++ b/src/pymatgen/io/abinit/inputs.py @@ -18,6 +18,7 @@ import numpy as np from monty.collections import AttrDict from monty.json import MSONable + from pymatgen.core.structure import Structure from pymatgen.io.abinit import abiobjects as aobj from pymatgen.io.abinit.pseudos import Pseudo, PseudoTable diff --git a/src/pymatgen/io/abinit/netcdf.py b/src/pymatgen/io/abinit/netcdf.py index 8c7538e46c8..fbde8ef1477 100644 --- a/src/pymatgen/io/abinit/netcdf.py +++ b/src/pymatgen/io/abinit/netcdf.py @@ -12,6 +12,7 @@ from monty.dev import requires from monty.functools import lazy_property from monty.string import marquee + from pymatgen.core.structure import Structure from pymatgen.core.units import ArrayWithUnit from pymatgen.core.xcfunc import XcFunc diff --git a/src/pymatgen/io/abinit/pseudos.py b/src/pymatgen/io/abinit/pseudos.py index b0927fe0484..5a56b93e1d3 100644 --- a/src/pymatgen/io/abinit/pseudos.py +++ b/src/pymatgen/io/abinit/pseudos.py @@ -24,11 +24,12 @@ from monty.itertools import iterator_from_slice from monty.json import MontyDecoder, MSONable from monty.os.path import find_exts +from tabulate import tabulate + from pymatgen.core import Element from pymatgen.core.xcfunc import XcFunc from pymatgen.io.core import ParseError from pymatgen.util.plotting import add_fig_kwargs, get_ax_fig -from tabulate import tabulate if TYPE_CHECKING: from collections.abc import Iterator, Sequence @@ -36,9 +37,10 @@ import matplotlib.pyplot as plt from numpy.typing import NDArray - from pymatgen.core import Structure from typing_extensions import Self + from pymatgen.core import Structure + logger = logging.getLogger(__name__) diff --git a/src/pymatgen/io/adf.py b/src/pymatgen/io/adf.py index 59a3d8bfabc..865493b697f 100644 --- a/src/pymatgen/io/adf.py +++ b/src/pymatgen/io/adf.py @@ -10,6 +10,7 @@ from monty.itertools import chunks from monty.json import MSONable from monty.serialization import zopen + from pymatgen.core.structure import Molecule if TYPE_CHECKING: diff --git a/src/pymatgen/io/aims/inputs.py b/src/pymatgen/io/aims/inputs.py index e03d0355f75..9ca84366b28 100644 --- a/src/pymatgen/io/aims/inputs.py +++ b/src/pymatgen/io/aims/inputs.py @@ -17,15 +17,17 @@ from monty.io import zopen from monty.json import MontyDecoder, MSONable from monty.os.path import zpath + from pymatgen.core import SETTINGS, Element, Lattice, Molecule, Structure if TYPE_CHECKING: from collections.abc import Sequence from typing import Any - from pymatgen.util.typing import Tuple3Floats, Tuple3Ints from typing_extensions import Self + from pymatgen.util.typing import Tuple3Floats, Tuple3Ints + __author__ = "Thomas A. R. Purcell" __version__ = "1.0" __email__ = "purcellt@arizona.edu" diff --git a/src/pymatgen/io/aims/outputs.py b/src/pymatgen/io/aims/outputs.py index f6012472ac5..45f680f6d84 100644 --- a/src/pymatgen/io/aims/outputs.py +++ b/src/pymatgen/io/aims/outputs.py @@ -6,6 +6,7 @@ import numpy as np from monty.json import MontyDecoder, MSONable + from pymatgen.io.aims.parsers import ( read_aims_header_info, read_aims_header_info_from_content, @@ -18,9 +19,10 @@ from pathlib import Path from typing import Any + from typing_extensions import Self + from pymatgen.core import Molecule, Structure from pymatgen.util.typing import Matrix3D, Vector3D - from typing_extensions import Self __author__ = "Andrey Sobolev and Thomas A. R. Purcell" __version__ = "1.0" diff --git a/src/pymatgen/io/aims/parsers.py b/src/pymatgen/io/aims/parsers.py index 3021c49279c..005a78f8aeb 100644 --- a/src/pymatgen/io/aims/parsers.py +++ b/src/pymatgen/io/aims/parsers.py @@ -8,6 +8,7 @@ from typing import TYPE_CHECKING, cast import numpy as np + from pymatgen.core import Lattice, Molecule, Structure from pymatgen.core.tensors import Tensor from pymatgen.util.typing import Tuple3Floats diff --git a/src/pymatgen/io/aims/sets/base.py b/src/pymatgen/io/aims/sets/base.py index c15385d9a2e..52ceed9b182 100644 --- a/src/pymatgen/io/aims/sets/base.py +++ b/src/pymatgen/io/aims/sets/base.py @@ -12,6 +12,7 @@ import numpy as np from monty.json import MontyDecoder, MontyEncoder + from pymatgen.core import Molecule, Structure from pymatgen.io.aims.inputs import AimsControlIn, AimsGeometryIn from pymatgen.io.aims.parsers import AimsParseError, read_aims_output diff --git a/src/pymatgen/io/ase.py b/src/pymatgen/io/ase.py index bae2dbc5a62..7058a9d2eee 100644 --- a/src/pymatgen/io/ase.py +++ b/src/pymatgen/io/ase.py @@ -12,6 +12,7 @@ import numpy as np from monty.json import MontyDecoder, MSONable, jsanitize + from pymatgen.core.structure import Molecule, Structure try: @@ -35,9 +36,10 @@ def __init__(self, *args, **kwargs): from typing import Any from numpy.typing import ArrayLike - from pymatgen.core.structure import SiteCollection from typing_extensions import Self + from pymatgen.core.structure import SiteCollection + __author__ = "Shyue Ping Ong, Andrew S. Rosen" __copyright__ = "Copyright 2012, The Materials Project" __version__ = "1.0" diff --git a/src/pymatgen/io/atat.py b/src/pymatgen/io/atat.py index 98660051d6b..7badcab828c 100644 --- a/src/pymatgen/io/atat.py +++ b/src/pymatgen/io/atat.py @@ -3,6 +3,7 @@ from __future__ import annotations import numpy as np + from pymatgen.core import Lattice, Structure, get_el_sp __author__ = "Matthew Horton" diff --git a/src/pymatgen/io/babel.py b/src/pymatgen/io/babel.py index a648a783831..0d0e19871c4 100644 --- a/src/pymatgen/io/babel.py +++ b/src/pymatgen/io/babel.py @@ -11,6 +11,7 @@ from typing import TYPE_CHECKING from monty.dev import requires + from pymatgen.core.structure import IMolecule, Molecule try: @@ -19,9 +20,10 @@ openbabel = pybel = None if TYPE_CHECKING: - from pymatgen.analysis.graphs import MoleculeGraph from typing_extensions import Self + from pymatgen.analysis.graphs import MoleculeGraph + __author__ = "Shyue Ping Ong, Qi Wang" __copyright__ = "Copyright 2012, The Materials Project" diff --git a/src/pymatgen/io/cif.py b/src/pymatgen/io/cif.py index 5020d66d83b..6b0a2453a71 100644 --- a/src/pymatgen/io/cif.py +++ b/src/pymatgen/io/cif.py @@ -19,6 +19,7 @@ from monty.dev import deprecated from monty.io import zopen from monty.serialization import loadfn + from pymatgen.core import Composition, DummySpecies, Element, Lattice, PeriodicSite, Species, Structure, get_el_sp from pymatgen.core.operations import MagSymmOp, SymmOp from pymatgen.electronic_structure.core import Magmom @@ -32,9 +33,10 @@ from typing import Any from numpy.typing import NDArray - from pymatgen.util.typing import PathLike, Vector3D from typing_extensions import Self + from pymatgen.util.typing import PathLike, Vector3D + __author__ = "Shyue Ping Ong, Will Richards, Matthew Horton" diff --git a/src/pymatgen/io/common.py b/src/pymatgen/io/common.py index 0949bf08306..00a0cac7932 100644 --- a/src/pymatgen/io/common.py +++ b/src/pymatgen/io/common.py @@ -11,10 +11,11 @@ import numpy as np from monty.io import zopen from monty.json import MSONable +from scipy.interpolate import RegularGridInterpolator + from pymatgen.core import Element, Site, Structure from pymatgen.core.units import ang_to_bohr, bohr_to_angstrom from pymatgen.electronic_structure.core import Spin -from scipy.interpolate import RegularGridInterpolator if TYPE_CHECKING: from pathlib import Path diff --git a/src/pymatgen/io/core.py b/src/pymatgen/io/core.py index c4c944706eb..1392e8a564e 100644 --- a/src/pymatgen/io/core.py +++ b/src/pymatgen/io/core.py @@ -37,9 +37,10 @@ from monty.json import MSONable if TYPE_CHECKING: - from pymatgen.util.typing import PathLike from typing_extensions import Self + from pymatgen.util.typing import PathLike + __author__ = "Ryan Kingsbury" __email__ = "RKingsbury@lbl.gov" diff --git a/src/pymatgen/io/cp2k/inputs.py b/src/pymatgen/io/cp2k/inputs.py index 83054d4380b..8076e51d09c 100644 --- a/src/pymatgen/io/cp2k/inputs.py +++ b/src/pymatgen/io/cp2k/inputs.py @@ -37,6 +37,7 @@ from monty.dev import deprecated from monty.io import zopen from monty.json import MSONable + from pymatgen.core import Element from pymatgen.io.cp2k.utils import chunk, postprocessor, preprocessor from pymatgen.io.vasp.inputs import Kpoints as VaspKpoints @@ -47,10 +48,11 @@ from collections.abc import Sequence from typing import Any, Literal + from typing_extensions import Self + from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Molecule, Structure from pymatgen.util.typing import Kpoint, Tuple3Ints - from typing_extensions import Self __author__ = "Nicholas Winner" __version__ = "2.0" diff --git a/src/pymatgen/io/cp2k/outputs.py b/src/pymatgen/io/cp2k/outputs.py index 0fecc2bd98b..19c63761eba 100644 --- a/src/pymatgen/io/cp2k/outputs.py +++ b/src/pymatgen/io/cp2k/outputs.py @@ -17,6 +17,7 @@ from monty.io import zopen from monty.json import MSONable, jsanitize from monty.re import regrep + from pymatgen.core.structure import Molecule, Structure from pymatgen.core.units import Ha_to_eV from pymatgen.electronic_structure.bandstructure import BandStructure, BandStructureSymmLine diff --git a/src/pymatgen/io/cp2k/sets.py b/src/pymatgen/io/cp2k/sets.py index 9af72d01594..d6fc950a583 100644 --- a/src/pymatgen/io/cp2k/sets.py +++ b/src/pymatgen/io/cp2k/sets.py @@ -24,6 +24,8 @@ import warnings import numpy as np +from ruamel.yaml import YAML + from pymatgen.core import SETTINGS from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Element, Molecule, Structure @@ -65,7 +67,6 @@ from pymatgen.io.cp2k.utils import get_truncated_coulomb_cutoff, get_unique_site_indices from pymatgen.io.vasp.inputs import Kpoints as VaspKpoints from pymatgen.io.vasp.inputs import KpointsSupportedModes -from ruamel.yaml import YAML __author__ = "Nicholas Winner" __version__ = "2.0" diff --git a/src/pymatgen/io/cssr.py b/src/pymatgen/io/cssr.py index 52d02996815..97631f3bf28 100644 --- a/src/pymatgen/io/cssr.py +++ b/src/pymatgen/io/cssr.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING from monty.io import zopen + from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure diff --git a/src/pymatgen/io/exciting/inputs.py b/src/pymatgen/io/exciting/inputs.py index 2a61fa77184..13f280c8fa0 100644 --- a/src/pymatgen/io/exciting/inputs.py +++ b/src/pymatgen/io/exciting/inputs.py @@ -10,6 +10,7 @@ import scipy.constants as const from monty.io import zopen from monty.json import MSONable + from pymatgen.core import Element, Lattice, Structure from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.symmetry.bandstructure import HighSymmKpath diff --git a/src/pymatgen/io/feff/inputs.py b/src/pymatgen/io/feff/inputs.py index 52e95a14521..5a3ed16ac35 100644 --- a/src/pymatgen/io/feff/inputs.py +++ b/src/pymatgen/io/feff/inputs.py @@ -15,13 +15,14 @@ import numpy as np from monty.io import zopen from monty.json import MSONable +from tabulate import tabulate + from pymatgen.core import Element, Lattice, Molecule, Structure from pymatgen.io.cif import CifParser from pymatgen.io.core import ParseError from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.io_utils import clean_lines from pymatgen.util.string import str_delimited -from tabulate import tabulate if TYPE_CHECKING: from typing_extensions import Self diff --git a/src/pymatgen/io/feff/outputs.py b/src/pymatgen/io/feff/outputs.py index 4337ee78741..133a28c7821 100644 --- a/src/pymatgen/io/feff/outputs.py +++ b/src/pymatgen/io/feff/outputs.py @@ -13,6 +13,7 @@ import numpy as np from monty.io import zopen from monty.json import MSONable + from pymatgen.core import Element from pymatgen.electronic_structure.core import Orbital, Spin from pymatgen.electronic_structure.dos import CompleteDos, Dos diff --git a/src/pymatgen/io/feff/sets.py b/src/pymatgen/io/feff/sets.py index 4231f1772ad..55ddd7fd588 100644 --- a/src/pymatgen/io/feff/sets.py +++ b/src/pymatgen/io/feff/sets.py @@ -20,6 +20,7 @@ from monty.json import MSONable from monty.os.path import zpath from monty.serialization import loadfn + from pymatgen.core.structure import Molecule, Structure from pymatgen.io.feff.inputs import Atoms, Header, Potential, Tags diff --git a/src/pymatgen/io/fiesta.py b/src/pymatgen/io/fiesta.py index dc75893c37a..45ad8954c72 100644 --- a/src/pymatgen/io/fiesta.py +++ b/src/pymatgen/io/fiesta.py @@ -17,14 +17,16 @@ from monty.io import zopen from monty.json import MSONable + from pymatgen.core.structure import Molecule if TYPE_CHECKING: from pathlib import Path - from pymatgen.util.typing import Tuple3Ints from typing_extensions import Self + from pymatgen.util.typing import Tuple3Ints + __author__ = "ndardenne" __copyright__ = "Copyright 2012, The Materials Project" __version__ = "0.1" diff --git a/src/pymatgen/io/gaussian.py b/src/pymatgen/io/gaussian.py index 36102e6c334..ca150bab18a 100644 --- a/src/pymatgen/io/gaussian.py +++ b/src/pymatgen/io/gaussian.py @@ -9,13 +9,14 @@ import numpy as np import scipy.constants as cst from monty.io import zopen +from scipy.stats import norm + from pymatgen.core import Composition, Element, Molecule from pymatgen.core.operations import SymmOp from pymatgen.core.units import Ha_to_eV from pymatgen.electronic_structure.core import Spin from pymatgen.util.coord import get_angle from pymatgen.util.plotting import pretty_plot -from scipy.stats import norm if TYPE_CHECKING: from pathlib import Path diff --git a/src/pymatgen/io/lammps/data.py b/src/pymatgen/io/lammps/data.py index 46ac9b97765..69d9d834853 100644 --- a/src/pymatgen/io/lammps/data.py +++ b/src/pymatgen/io/lammps/data.py @@ -27,18 +27,20 @@ from monty.io import zopen from monty.json import MSONable from monty.serialization import loadfn +from ruamel.yaml import YAML + from pymatgen.core import Element, Lattice, Molecule, Structure from pymatgen.core.operations import SymmOp from pymatgen.util.io_utils import clean_lines -from ruamel.yaml import YAML if TYPE_CHECKING: from collections.abc import Sequence from typing import Any, Literal + from typing_extensions import Self + from pymatgen.core.sites import Site from pymatgen.core.structure import SiteCollection - from typing_extensions import Self __author__ = "Kiran Mathew, Zhi Deng, Tingzheng Hou" __copyright__ = "Copyright 2018, The Materials Virtual Lab" diff --git a/src/pymatgen/io/lammps/generators.py b/src/pymatgen/io/lammps/generators.py index 5e1c0a30950..afc2f39b5dc 100644 --- a/src/pymatgen/io/lammps/generators.py +++ b/src/pymatgen/io/lammps/generators.py @@ -15,6 +15,7 @@ from string import Template from monty.io import zopen + from pymatgen.core import Structure from pymatgen.io.core import InputGenerator from pymatgen.io.lammps.data import CombinedData, LammpsData diff --git a/src/pymatgen/io/lammps/inputs.py b/src/pymatgen/io/lammps/inputs.py index 5ea8477d5fd..565feea80bf 100644 --- a/src/pymatgen/io/lammps/inputs.py +++ b/src/pymatgen/io/lammps/inputs.py @@ -19,6 +19,7 @@ from monty.dev import deprecated from monty.io import zopen from monty.json import MSONable + from pymatgen.core import __version__ as CURRENT_VER from pymatgen.io.core import InputFile from pymatgen.io.lammps.data import CombinedData, LammpsData @@ -27,9 +28,10 @@ if TYPE_CHECKING: from os import PathLike - from pymatgen.io.core import InputSet from typing_extensions import Self + from pymatgen.io.core import InputSet + __author__ = "Kiran Mathew, Brandon Wood, Zhi Deng, Manas Likhit, Guillaume Brunin (Matgenix)" __copyright__ = "Copyright 2018, The Materials Virtual Lab" __version__ = "2.0" diff --git a/src/pymatgen/io/lammps/outputs.py b/src/pymatgen/io/lammps/outputs.py index b8e9688c06d..033a7d58b4a 100644 --- a/src/pymatgen/io/lammps/outputs.py +++ b/src/pymatgen/io/lammps/outputs.py @@ -14,6 +14,7 @@ import pandas as pd from monty.io import zopen from monty.json import MSONable + from pymatgen.io.lammps.data import LammpsBox if TYPE_CHECKING: diff --git a/src/pymatgen/io/lammps/sets.py b/src/pymatgen/io/lammps/sets.py index 54e63afd5f2..d61510f3d67 100644 --- a/src/pymatgen/io/lammps/sets.py +++ b/src/pymatgen/io/lammps/sets.py @@ -18,9 +18,10 @@ from pymatgen.io.lammps.inputs import LammpsInputFile if TYPE_CHECKING: - from pymatgen.util.typing import PathLike from typing_extensions import Self + from pymatgen.util.typing import PathLike + __author__ = "Ryan Kingsbury, Guillaume Brunin (Matgenix)" __copyright__ = "Copyright 2021, The Materials Project" __version__ = "0.2" diff --git a/src/pymatgen/io/lammps/utils.py b/src/pymatgen/io/lammps/utils.py index cc8537d8af6..2ccca0ea2e0 100644 --- a/src/pymatgen/io/lammps/utils.py +++ b/src/pymatgen/io/lammps/utils.py @@ -11,6 +11,7 @@ import numpy as np from monty.dev import deprecated from monty.tempfile import ScratchDir + from pymatgen.core.operations import SymmOp from pymatgen.core.structure import Molecule from pymatgen.io.babel import BabelMolAdaptor diff --git a/src/pymatgen/io/lmto.py b/src/pymatgen/io/lmto.py index 5c6057d8190..747a65ca42e 100644 --- a/src/pymatgen/io/lmto.py +++ b/src/pymatgen/io/lmto.py @@ -11,6 +11,7 @@ import numpy as np from monty.io import zopen + from pymatgen.core.structure import Structure from pymatgen.core.units import Ry_to_eV, bohr_to_angstrom from pymatgen.electronic_structure.core import Spin diff --git a/src/pymatgen/io/lobster/inputs.py b/src/pymatgen/io/lobster/inputs.py index f3759a38b93..9eef7c654a0 100644 --- a/src/pymatgen/io/lobster/inputs.py +++ b/src/pymatgen/io/lobster/inputs.py @@ -22,6 +22,7 @@ from monty.io import zopen from monty.json import MSONable from monty.serialization import loadfn + from pymatgen.core.structure import Structure from pymatgen.io.vasp import Vasprun from pymatgen.io.vasp.inputs import Incar, Kpoints, Potcar @@ -31,9 +32,10 @@ if TYPE_CHECKING: from typing import Any, ClassVar, Literal + from typing_extensions import Self + from pymatgen.core.composition import Composition from pymatgen.util.typing import PathLike, Tuple3Ints - from typing_extensions import Self MODULE_DIR = os.path.dirname(os.path.abspath(__file__)) diff --git a/src/pymatgen/io/lobster/lobsterenv.py b/src/pymatgen/io/lobster/lobsterenv.py index 7982b025c99..919ea6bb678 100644 --- a/src/pymatgen/io/lobster/lobsterenv.py +++ b/src/pymatgen/io/lobster/lobsterenv.py @@ -20,6 +20,7 @@ import numpy as np from monty.dev import deprecated + from pymatgen.analysis.bond_valence import BVAnalyzer from pymatgen.analysis.chemenv.coordination_environments.coordination_geometry_finder import LocalGeometryFinder from pymatgen.analysis.chemenv.coordination_environments.structure_environments import LightStructureEnvironments @@ -31,9 +32,10 @@ from pymatgen.util.due import Doi, due if TYPE_CHECKING: + from typing_extensions import Self + from pymatgen.core import Structure from pymatgen.core.periodic_table import Element - from typing_extensions import Self __author__ = "Janine George" __copyright__ = "Copyright 2021, The Materials Project" diff --git a/src/pymatgen/io/lobster/outputs.py b/src/pymatgen/io/lobster/outputs.py index d17c550ba9b..aacc38332b4 100644 --- a/src/pymatgen/io/lobster/outputs.py +++ b/src/pymatgen/io/lobster/outputs.py @@ -22,6 +22,7 @@ import numpy as np from monty.io import zopen from monty.json import MSONable + from pymatgen.core.structure import Structure from pymatgen.electronic_structure.bandstructure import LobsterBandStructureSymmLine from pymatgen.electronic_structure.core import Orbital, Spin diff --git a/src/pymatgen/io/nwchem.py b/src/pymatgen/io/nwchem.py index 8b39dcb40e3..04686e878f7 100644 --- a/src/pymatgen/io/nwchem.py +++ b/src/pymatgen/io/nwchem.py @@ -29,6 +29,7 @@ import numpy as np from monty.io import zopen from monty.json import MSONable + from pymatgen.analysis.excitation import ExcitationSpectrum from pymatgen.core.structure import Molecule, Structure from pymatgen.core.units import Energy, FloatWithUnit diff --git a/src/pymatgen/io/openff.py b/src/pymatgen/io/openff.py index bef308811d5..37e610409c0 100644 --- a/src/pymatgen/io/openff.py +++ b/src/pymatgen/io/openff.py @@ -6,6 +6,7 @@ from pathlib import Path import numpy as np + import pymatgen from pymatgen.analysis.graphs import MoleculeGraph from pymatgen.analysis.local_env import OpenBabelNN, metal_edge_extender diff --git a/src/pymatgen/io/packmol.py b/src/pymatgen/io/packmol.py index d1f1f7f6c6a..ed159029864 100644 --- a/src/pymatgen/io/packmol.py +++ b/src/pymatgen/io/packmol.py @@ -26,6 +26,7 @@ class that provides a run() method for running packmol locally. from typing import TYPE_CHECKING import numpy as np + from pymatgen.core import Molecule from pymatgen.io.core import InputGenerator, InputSet diff --git a/src/pymatgen/io/phonopy.py b/src/pymatgen/io/phonopy.py index 6e156b2e2e5..d0d39f014e4 100644 --- a/src/pymatgen/io/phonopy.py +++ b/src/pymatgen/io/phonopy.py @@ -5,13 +5,14 @@ import numpy as np from monty.dev import requires from monty.serialization import loadfn +from scipy.interpolate import InterpolatedUnivariateSpline + from pymatgen.core import Lattice, Structure from pymatgen.phonon.bandstructure import PhononBandStructure, PhononBandStructureSymmLine from pymatgen.phonon.dos import CompletePhononDos, PhononDos from pymatgen.phonon.gruneisen import GruneisenParameter, GruneisenPhononBandStructureSymmLine from pymatgen.phonon.thermal_displacements import ThermalDisplacementMatrices from pymatgen.symmetry.bandstructure import HighSymmKpath -from scipy.interpolate import InterpolatedUnivariateSpline try: from phonopy import Phonopy diff --git a/src/pymatgen/io/pwmat/inputs.py b/src/pymatgen/io/pwmat/inputs.py index 1051405ffe9..a0330270d00 100644 --- a/src/pymatgen/io/pwmat/inputs.py +++ b/src/pymatgen/io/pwmat/inputs.py @@ -8,13 +8,15 @@ import numpy as np from monty.io import zopen from monty.json import MSONable + from pymatgen.core import Lattice, Structure from pymatgen.symmetry.kpath import KPathSeek if TYPE_CHECKING: - from pymatgen.util.typing import PathLike from typing_extensions import Self + from pymatgen.util.typing import PathLike + __author__ = "Hanyu Liu" __email__ = "domainofbuaa@gmail.com" __date__ = "2024-1-16" diff --git a/src/pymatgen/io/pwmat/outputs.py b/src/pymatgen/io/pwmat/outputs.py index 0ebd966efd2..3daf32b57c0 100644 --- a/src/pymatgen/io/pwmat/outputs.py +++ b/src/pymatgen/io/pwmat/outputs.py @@ -8,6 +8,7 @@ import numpy as np from monty.io import zopen from monty.json import MSONable + from pymatgen.io.pwmat.inputs import ACstrExtractor, AtomConfig, LineLocator if TYPE_CHECKING: diff --git a/src/pymatgen/io/pwscf.py b/src/pymatgen/io/pwscf.py index 2af861b9941..73aa43f4a55 100644 --- a/src/pymatgen/io/pwscf.py +++ b/src/pymatgen/io/pwscf.py @@ -8,6 +8,7 @@ from monty.io import zopen from monty.re import regrep + from pymatgen.core import Element, Lattice, Structure from pymatgen.util.io_utils import clean_lines diff --git a/src/pymatgen/io/qchem/inputs.py b/src/pymatgen/io/qchem/inputs.py index bb20603c8bd..27f2816103e 100644 --- a/src/pymatgen/io/qchem/inputs.py +++ b/src/pymatgen/io/qchem/inputs.py @@ -7,6 +7,7 @@ from typing import TYPE_CHECKING from monty.io import zopen + from pymatgen.core import Molecule from pymatgen.io.core import InputFile diff --git a/src/pymatgen/io/qchem/outputs.py b/src/pymatgen/io/qchem/outputs.py index 6db29b910ac..c2cccd2ddc9 100644 --- a/src/pymatgen/io/qchem/outputs.py +++ b/src/pymatgen/io/qchem/outputs.py @@ -16,6 +16,7 @@ import pandas as pd from monty.io import zopen from monty.json import MSONable, jsanitize + from pymatgen.analysis.graphs import MoleculeGraph from pymatgen.analysis.local_env import OpenBabelNN from pymatgen.core import Molecule diff --git a/src/pymatgen/io/qchem/sets.py b/src/pymatgen/io/qchem/sets.py index 7be1ddbc67a..1b40d49fb4c 100644 --- a/src/pymatgen/io/qchem/sets.py +++ b/src/pymatgen/io/qchem/sets.py @@ -8,6 +8,7 @@ from typing import TYPE_CHECKING from monty.io import zopen + from pymatgen.io.qchem.inputs import QCInput from pymatgen.io.qchem.utils import lower_and_check_unique diff --git a/src/pymatgen/io/res.py b/src/pymatgen/io/res.py index 6218392ed1e..d43efbaaf00 100644 --- a/src/pymatgen/io/res.py +++ b/src/pymatgen/io/res.py @@ -17,6 +17,7 @@ from monty.io import zopen from monty.json import MSONable + from pymatgen.core import Element, Lattice, PeriodicSite, Structure from pymatgen.entries.computed_entries import ComputedStructureEntry from pymatgen.io.core import ParseError @@ -27,9 +28,10 @@ from pathlib import Path from typing import Any, Callable, Literal - from pymatgen.util.typing import Tuple3Ints, Vector3D from typing_extensions import Self + from pymatgen.util.typing import Tuple3Ints, Vector3D + @dataclass(frozen=True) class AirssTITL: diff --git a/src/pymatgen/io/shengbte.py b/src/pymatgen/io/shengbte.py index 7ccdee00c23..bd8009d93cb 100644 --- a/src/pymatgen/io/shengbte.py +++ b/src/pymatgen/io/shengbte.py @@ -8,6 +8,7 @@ import numpy as np from monty.dev import requires from monty.json import MSONable + from pymatgen.core.structure import Structure from pymatgen.io.vasp import Kpoints diff --git a/src/pymatgen/io/template.py b/src/pymatgen/io/template.py index 6103f09d105..2ee08031ede 100644 --- a/src/pymatgen/io/template.py +++ b/src/pymatgen/io/template.py @@ -9,6 +9,7 @@ from typing import TYPE_CHECKING from monty.io import zopen + from pymatgen.io.core import InputGenerator, InputSet if TYPE_CHECKING: diff --git a/src/pymatgen/io/vasp/inputs.py b/src/pymatgen/io/vasp/inputs.py index 25572a2b1ab..cda9ff18cf6 100644 --- a/src/pymatgen/io/vasp/inputs.py +++ b/src/pymatgen/io/vasp/inputs.py @@ -31,21 +31,23 @@ from monty.os import cd from monty.os.path import zpath from monty.serialization import dumpfn, loadfn +from tabulate import tabulate + from pymatgen.core import SETTINGS, Element, Lattice, Structure, get_el_sp from pymatgen.electronic_structure.core import Magmom from pymatgen.util.io_utils import clean_lines from pymatgen.util.string import str_delimited from pymatgen.util.typing import Kpoint, Tuple3Floats, Tuple3Ints, Vector3D -from tabulate import tabulate if TYPE_CHECKING: from collections.abc import Iterator from typing import Any, ClassVar, Literal from numpy.typing import ArrayLike + from typing_extensions import Self + from pymatgen.symmetry.bandstructure import HighSymmKpath from pymatgen.util.typing import PathLike - from typing_extensions import Self __author__ = "Shyue Ping Ong, Geoffroy Hautier, Rickard Armiento, Vincent L Chevrier, Stephen Dacek" diff --git a/src/pymatgen/io/vasp/optics.py b/src/pymatgen/io/vasp/optics.py index bc52f8ec197..9e1e1b66cf7 100644 --- a/src/pymatgen/io/vasp/optics.py +++ b/src/pymatgen/io/vasp/optics.py @@ -10,15 +10,17 @@ import scipy.constants import scipy.special from monty.json import MSONable +from tqdm import tqdm + from pymatgen.electronic_structure.core import Spin from pymatgen.io.vasp.outputs import Vasprun, Waveder -from tqdm import tqdm if TYPE_CHECKING: from numpy.typing import ArrayLike, NDArray - from pymatgen.util.typing import PathLike from typing_extensions import Self + from pymatgen.util.typing import PathLike + __author__ = "Jimmy-Xuan Shen" __copyright__ = "Copyright 2022, The Materials Project" __maintainer__ = "Jimmy-Xuan Shen" diff --git a/src/pymatgen/io/vasp/outputs.py b/src/pymatgen/io/vasp/outputs.py index 9df9d6dadc9..c79a46b6618 100644 --- a/src/pymatgen/io/vasp/outputs.py +++ b/src/pymatgen/io/vasp/outputs.py @@ -24,6 +24,7 @@ from monty.os.path import zpath from monty.re import regrep from numpy.testing import assert_allclose + from pymatgen.core import Composition, Element, Lattice, Structure from pymatgen.core.trajectory import Trajectory from pymatgen.core.units import unitized @@ -50,9 +51,10 @@ from xml.etree.ElementTree import Element as XML_Element from numpy.typing import NDArray - from pymatgen.util.typing import PathLike from typing_extensions import Self + from pymatgen.util.typing import PathLike + logger = logging.getLogger(__name__) diff --git a/src/pymatgen/io/vasp/sets.py b/src/pymatgen/io/vasp/sets.py index 5bc09f6d46b..08ce0dedb18 100644 --- a/src/pymatgen/io/vasp/sets.py +++ b/src/pymatgen/io/vasp/sets.py @@ -45,6 +45,7 @@ from monty.dev import deprecated from monty.json import MSONable from monty.serialization import loadfn + from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core import Element, PeriodicSite, SiteCollection, Species, Structure from pymatgen.io.core import InputGenerator @@ -58,9 +59,10 @@ if TYPE_CHECKING: from typing import Callable, Literal, Union - from pymatgen.util.typing import PathLike, Tuple3Ints, Vector3D from typing_extensions import Self + from pymatgen.util.typing import PathLike, Tuple3Ints, Vector3D + UserPotcarFunctional = Union[ Literal["PBE", "PBE_52", "PBE_54", "LDA", "LDA_52", "LDA_54", "PW91", "LDA_US", "PW91_US"], None ] diff --git a/src/pymatgen/io/xr.py b/src/pymatgen/io/xr.py index 3fb644c11bd..645c8a6910c 100644 --- a/src/pymatgen/io/xr.py +++ b/src/pymatgen/io/xr.py @@ -15,6 +15,7 @@ import numpy as np from monty.io import zopen + from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure diff --git a/src/pymatgen/io/xtb/outputs.py b/src/pymatgen/io/xtb/outputs.py index 60ca8c52834..4751c251a8f 100644 --- a/src/pymatgen/io/xtb/outputs.py +++ b/src/pymatgen/io/xtb/outputs.py @@ -7,6 +7,7 @@ import re from monty.json import MSONable + from pymatgen.core import Molecule from pymatgen.io.xyz import XYZ diff --git a/src/pymatgen/io/xyz.py b/src/pymatgen/io/xyz.py index 28914a47010..81430321a28 100644 --- a/src/pymatgen/io/xyz.py +++ b/src/pymatgen/io/xyz.py @@ -8,6 +8,7 @@ import pandas as pd from monty.io import zopen + from pymatgen.core import Molecule, Structure from pymatgen.core.structure import SiteCollection diff --git a/src/pymatgen/io/zeopp.py b/src/pymatgen/io/zeopp.py index 5ebee530013..fa8299a2925 100644 --- a/src/pymatgen/io/zeopp.py +++ b/src/pymatgen/io/zeopp.py @@ -31,6 +31,7 @@ from monty.dev import requires from monty.io import zopen from monty.tempfile import ScratchDir + from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Molecule, Structure from pymatgen.io.cssr import Cssr diff --git a/src/pymatgen/phonon/bandstructure.py b/src/pymatgen/phonon/bandstructure.py index 17cb899b948..d56ff99df89 100644 --- a/src/pymatgen/phonon/bandstructure.py +++ b/src/pymatgen/phonon/bandstructure.py @@ -7,6 +7,7 @@ import numpy as np from monty.json import MSONable + from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.electronic_structure.bandstructure import Kpoint @@ -17,9 +18,10 @@ from typing import Any from numpy.typing import ArrayLike - from pymatgen.util.typing import Tuple3Ints from typing_extensions import Self + from pymatgen.util.typing import Tuple3Ints + def get_reasonable_repetitions(n_atoms: int) -> Tuple3Ints: """Choose the number of repetitions in a supercell diff --git a/src/pymatgen/phonon/dos.py b/src/pymatgen/phonon/dos.py index 0e3e0ea2296..e4e26c192d4 100644 --- a/src/pymatgen/phonon/dos.py +++ b/src/pymatgen/phonon/dos.py @@ -8,9 +8,10 @@ import scipy.constants as const from monty.functools import lazy_property from monty.json import MSONable +from scipy.ndimage import gaussian_filter1d + from pymatgen.core.structure import Structure from pymatgen.util.coord import get_linear_interpolated_value -from scipy.ndimage import gaussian_filter1d if TYPE_CHECKING: from collections.abc import Sequence diff --git a/src/pymatgen/phonon/gruneisen.py b/src/pymatgen/phonon/gruneisen.py index 67517b4faa7..a4aee2cc443 100644 --- a/src/pymatgen/phonon/gruneisen.py +++ b/src/pymatgen/phonon/gruneisen.py @@ -8,12 +8,13 @@ import scipy.constants as const from monty.dev import requires from monty.json import MSONable +from scipy.interpolate import UnivariateSpline + from pymatgen.core import Structure from pymatgen.core.lattice import Lattice from pymatgen.core.units import amu_to_kg from pymatgen.phonon.bandstructure import PhononBandStructure, PhononBandStructureSymmLine from pymatgen.phonon.dos import PhononDos -from scipy.interpolate import UnivariateSpline try: import phonopy diff --git a/src/pymatgen/phonon/ir_spectra.py b/src/pymatgen/phonon/ir_spectra.py index 9626e6c5726..462f4fa94b9 100644 --- a/src/pymatgen/phonon/ir_spectra.py +++ b/src/pymatgen/phonon/ir_spectra.py @@ -11,6 +11,7 @@ import numpy as np from monty.json import MSONable + from pymatgen.core.spectrum import Spectrum from pymatgen.core.structure import Structure from pymatgen.util.plotting import add_fig_kwargs diff --git a/src/pymatgen/phonon/plotter.py b/src/pymatgen/phonon/plotter.py index d5dd63bc2ec..652287e3af2 100644 --- a/src/pymatgen/phonon/plotter.py +++ b/src/pymatgen/phonon/plotter.py @@ -12,6 +12,7 @@ from matplotlib.collections import LineCollection from matplotlib.colors import LinearSegmentedColormap from monty.json import jsanitize + from pymatgen.electronic_structure.plotter import BSDOSPlotter, plot_brillouin_zone from pymatgen.phonon.bandstructure import PhononBandStructureSymmLine from pymatgen.phonon.gruneisen import GruneisenPhononBandStructureSymmLine @@ -24,6 +25,7 @@ from matplotlib.axes import Axes from matplotlib.figure import Figure + from pymatgen.core import Structure from pymatgen.phonon.dos import PhononDos from pymatgen.phonon.gruneisen import GruneisenParameter diff --git a/src/pymatgen/phonon/thermal_displacements.py b/src/pymatgen/phonon/thermal_displacements.py index 818b5f6f911..b021cbc57b3 100644 --- a/src/pymatgen/phonon/thermal_displacements.py +++ b/src/pymatgen/phonon/thermal_displacements.py @@ -8,6 +8,7 @@ import numpy as np from monty.json import MSONable + from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core.structure import Structure from pymatgen.io.cif import CifFile, CifParser, CifWriter, str2float diff --git a/src/pymatgen/symmetry/analyzer.py b/src/pymatgen/symmetry/analyzer.py index f404aa2170b..c41407e1703 100644 --- a/src/pymatgen/symmetry/analyzer.py +++ b/src/pymatgen/symmetry/analyzer.py @@ -25,6 +25,7 @@ import numpy as np import scipy.cluster import spglib + from pymatgen.core.lattice import Lattice from pymatgen.core.operations import SymmOp from pymatgen.core.structure import Molecule, PeriodicSite, Structure @@ -36,11 +37,12 @@ from typing import Any, Literal from numpy.typing import NDArray + from spglib import SpglibDataset + from pymatgen.core import Element, Species from pymatgen.core.sites import Site from pymatgen.symmetry.groups import CrystalSystem from pymatgen.util.typing import Kpoint - from spglib import SpglibDataset LatticeType = Literal["cubic", "hexagonal", "monoclinic", "orthorhombic", "rhombohedral", "tetragonal", "triclinic"] diff --git a/src/pymatgen/symmetry/bandstructure.py b/src/pymatgen/symmetry/bandstructure.py index c37009792e1..05d416a0fbe 100644 --- a/src/pymatgen/symmetry/bandstructure.py +++ b/src/pymatgen/symmetry/bandstructure.py @@ -9,6 +9,7 @@ import networkx as nx import numpy as np + from pymatgen.electronic_structure.bandstructure import BandStructureSymmLine from pymatgen.electronic_structure.core import Spin from pymatgen.symmetry.analyzer import cite_conventional_cell_algo diff --git a/src/pymatgen/symmetry/groups.py b/src/pymatgen/symmetry/groups.py index fab21815d5e..dd1510c0289 100644 --- a/src/pymatgen/symmetry/groups.py +++ b/src/pymatgen/symmetry/groups.py @@ -17,17 +17,19 @@ import numpy as np from monty.design_patterns import cached_class from monty.serialization import loadfn + from pymatgen.util.string import Stringify if TYPE_CHECKING: from typing import ClassVar, Literal from numpy.typing import ArrayLike + from typing_extensions import Self + from pymatgen.core.lattice import Lattice # Don't import at runtime to avoid circular import from pymatgen.core.operations import SymmOp # noqa: TCH004 - from typing_extensions import Self CrystalSystem = Literal["cubic", "hexagonal", "monoclinic", "orthorhombic", "tetragonal", "triclinic", "trigonal"] diff --git a/src/pymatgen/symmetry/kpath.py b/src/pymatgen/symmetry/kpath.py index a1983f5047d..222dab404d3 100644 --- a/src/pymatgen/symmetry/kpath.py +++ b/src/pymatgen/symmetry/kpath.py @@ -12,6 +12,7 @@ import numpy as np import spglib from monty.dev import requires + from pymatgen.core.lattice import Lattice from pymatgen.core.operations import MagSymmOp, SymmOp from pymatgen.symmetry.analyzer import SpacegroupAnalyzer, cite_conventional_cell_algo diff --git a/src/pymatgen/symmetry/maggroups.py b/src/pymatgen/symmetry/maggroups.py index 1b7b72ee33a..33270ee8c82 100644 --- a/src/pymatgen/symmetry/maggroups.py +++ b/src/pymatgen/symmetry/maggroups.py @@ -11,6 +11,7 @@ import numpy as np from monty.design_patterns import cached_class + from pymatgen.core.operations import MagSymmOp from pymatgen.electronic_structure.core import Magmom from pymatgen.symmetry.groups import SymmetryGroup, in_array_list @@ -20,9 +21,10 @@ if TYPE_CHECKING: from collections.abc import Sequence - from pymatgen.core.lattice import Lattice from typing_extensions import Self + from pymatgen.core.lattice import Lattice + __author__ = "Matthew Horton, Shyue Ping Ong" MAGSYMM_DATA = os.path.join(os.path.dirname(__file__), "symm_data_magnetic.sqlite") diff --git a/src/pymatgen/symmetry/settings.py b/src/pymatgen/symmetry/settings.py index 99597c1cbe3..3abd7f547f3 100644 --- a/src/pymatgen/symmetry/settings.py +++ b/src/pymatgen/symmetry/settings.py @@ -7,11 +7,12 @@ from typing import TYPE_CHECKING import numpy as np +from sympy import Matrix +from sympy.parsing.sympy_parser import parse_expr + from pymatgen.core.lattice import Lattice from pymatgen.core.operations import MagSymmOp, SymmOp from pymatgen.util.string import transformation_to_string -from sympy import Matrix -from sympy.parsing.sympy_parser import parse_expr if TYPE_CHECKING: from typing_extensions import Self diff --git a/src/pymatgen/symmetry/site_symmetries.py b/src/pymatgen/symmetry/site_symmetries.py index ed889cb5f72..c73a321270a 100644 --- a/src/pymatgen/symmetry/site_symmetries.py +++ b/src/pymatgen/symmetry/site_symmetries.py @@ -5,6 +5,7 @@ from typing import TYPE_CHECKING import numpy as np + from pymatgen.core.operations import SymmOp from pymatgen.symmetry.analyzer import SpacegroupAnalyzer diff --git a/src/pymatgen/symmetry/structure.py b/src/pymatgen/symmetry/structure.py index 093b5f8af39..22d975c9b53 100644 --- a/src/pymatgen/symmetry/structure.py +++ b/src/pymatgen/symmetry/structure.py @@ -5,15 +5,17 @@ from typing import TYPE_CHECKING import numpy as np -from pymatgen.core.structure import PeriodicSite, Structure from tabulate import tabulate +from pymatgen.core.structure import PeriodicSite, Structure + if TYPE_CHECKING: from collections.abc import Sequence - from pymatgen.symmetry.analyzer import SpacegroupOperations from typing_extensions import Self + from pymatgen.symmetry.analyzer import SpacegroupOperations + class SymmetrizedStructure(Structure): """This class represents a symmetrized structure, i.e. a structure diff --git a/src/pymatgen/transformations/advanced_transformations.py b/src/pymatgen/transformations/advanced_transformations.py index 57b89c43efe..fa1b209915f 100644 --- a/src/pymatgen/transformations/advanced_transformations.py +++ b/src/pymatgen/transformations/advanced_transformations.py @@ -16,6 +16,7 @@ from monty.dev import requires from monty.fractions import lcm from monty.json import MSONable + from pymatgen.analysis.adsorption import AdsorbateSiteFinder from pymatgen.analysis.bond_valence import BVAnalyzer from pymatgen.analysis.energy_models import SymmetryModel diff --git a/src/pymatgen/transformations/site_transformations.py b/src/pymatgen/transformations/site_transformations.py index 7ba3151fc90..220769fd0f4 100644 --- a/src/pymatgen/transformations/site_transformations.py +++ b/src/pymatgen/transformations/site_transformations.py @@ -14,6 +14,7 @@ import numpy as np from monty.json import MSONable + from pymatgen.analysis.ewald import EwaldMinimizer, EwaldSummation from pymatgen.analysis.local_env import MinimumDistanceNN from pymatgen.symmetry.analyzer import SpacegroupAnalyzer diff --git a/src/pymatgen/transformations/standard_transformations.py b/src/pymatgen/transformations/standard_transformations.py index 616c7de84a7..92bbe883da7 100644 --- a/src/pymatgen/transformations/standard_transformations.py +++ b/src/pymatgen/transformations/standard_transformations.py @@ -12,6 +12,7 @@ import numpy as np from numpy import around + from pymatgen.analysis.bond_valence import BVAnalyzer from pymatgen.analysis.elasticity.strain import Deformation from pymatgen.analysis.ewald import EwaldMinimizer, EwaldSummation @@ -24,9 +25,10 @@ from pymatgen.transformations.transformation_abc import AbstractTransformation if TYPE_CHECKING: + from typing_extensions import Self + from pymatgen.core.sites import PeriodicSite from pymatgen.util.typing import SpeciesLike - from typing_extensions import Self logger = logging.getLogger(__name__) diff --git a/src/pymatgen/util/coord.py b/src/pymatgen/util/coord.py index e00dceb5655..eabbc2dadfa 100644 --- a/src/pymatgen/util/coord.py +++ b/src/pymatgen/util/coord.py @@ -11,6 +11,7 @@ import numpy as np from monty.json import MSONable + from pymatgen.util import coord_cython if TYPE_CHECKING: @@ -18,6 +19,7 @@ from typing import Literal from numpy.typing import ArrayLike + from pymatgen.util.typing import PbcLike diff --git a/src/pymatgen/util/plotting.py b/src/pymatgen/util/plotting.py index b94cba844e0..13958cc9b22 100644 --- a/src/pymatgen/util/plotting.py +++ b/src/pymatgen/util/plotting.py @@ -12,6 +12,7 @@ import numpy as np import palettable.colorbrewer.diverging from matplotlib import cm, colors + from pymatgen.core import Element if TYPE_CHECKING: diff --git a/src/pymatgen/util/provenance.py b/src/pymatgen/util/provenance.py index 0e72704b1cc..7fcb5c54a4b 100644 --- a/src/pymatgen/util/provenance.py +++ b/src/pymatgen/util/provenance.py @@ -10,6 +10,7 @@ from typing import TYPE_CHECKING, NamedTuple from monty.json import MontyDecoder, MontyEncoder + from pymatgen.core.structure import Molecule, Structure try: diff --git a/src/pymatgen/util/testing/__init__.py b/src/pymatgen/util/testing/__init__.py index 211690effa9..9ec92a8ee25 100644 --- a/src/pymatgen/util/testing/__init__.py +++ b/src/pymatgen/util/testing/__init__.py @@ -17,6 +17,7 @@ import pytest from monty.json import MontyDecoder, MontyEncoder, MSONable from monty.serialization import loadfn + from pymatgen.core import ROOT, SETTINGS, Structure if TYPE_CHECKING: diff --git a/src/pymatgen/util/testing/aims.py b/src/pymatgen/util/testing/aims.py index ce5b85525a7..057df663083 100644 --- a/src/pymatgen/util/testing/aims.py +++ b/src/pymatgen/util/testing/aims.py @@ -10,6 +10,7 @@ import numpy as np from monty.io import zopen + from pymatgen.core import Molecule, Structure diff --git a/src/pymatgen/vis/plotters.py b/src/pymatgen/vis/plotters.py index e77d4c92ccb..5670e24f8ae 100644 --- a/src/pymatgen/vis/plotters.py +++ b/src/pymatgen/vis/plotters.py @@ -5,6 +5,7 @@ import importlib import matplotlib.pyplot as plt + from pymatgen.util.plotting import pretty_plot diff --git a/src/pymatgen/vis/structure_chemview.py b/src/pymatgen/vis/structure_chemview.py index 73069535a91..9007bb9446f 100644 --- a/src/pymatgen/vis/structure_chemview.py +++ b/src/pymatgen/vis/structure_chemview.py @@ -3,6 +3,7 @@ from __future__ import annotations import numpy as np + from pymatgen.analysis.molecule_structure_comparator import CovalentRadius from pymatgen.symmetry.analyzer import SpacegroupAnalyzer diff --git a/src/pymatgen/vis/structure_vtk.py b/src/pymatgen/vis/structure_vtk.py index cdb15313a80..c2329591744 100644 --- a/src/pymatgen/vis/structure_vtk.py +++ b/src/pymatgen/vis/structure_vtk.py @@ -12,6 +12,7 @@ import numpy as np from monty.dev import requires from monty.serialization import loadfn + from pymatgen.core import PeriodicSite, Species, Structure from pymatgen.util.coord import in_coord_list diff --git a/tests/alchemy/test_filters.py b/tests/alchemy/test_filters.py index 418213e1dd3..16737ae67fa 100644 --- a/tests/alchemy/test_filters.py +++ b/tests/alchemy/test_filters.py @@ -4,6 +4,7 @@ from unittest import TestCase from monty.json import MontyDecoder + from pymatgen.alchemy.filters import ( ContainsSpecieFilter, RemoveDuplicatesFilter, diff --git a/tests/alchemy/test_materials.py b/tests/alchemy/test_materials.py index 0ec5c800f01..c667b27277e 100644 --- a/tests/alchemy/test_materials.py +++ b/tests/alchemy/test_materials.py @@ -4,6 +4,7 @@ from copy import deepcopy import pytest + from pymatgen.alchemy.filters import ContainsSpecieFilter from pymatgen.alchemy.materials import TransformedStructure from pymatgen.core import SETTINGS diff --git a/tests/analysis/chemenv/connectivity/test_connected_components.py b/tests/analysis/chemenv/connectivity/test_connected_components.py index dc9b01e62ea..2768fc5b815 100644 --- a/tests/analysis/chemenv/connectivity/test_connected_components.py +++ b/tests/analysis/chemenv/connectivity/test_connected_components.py @@ -7,6 +7,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose + from pymatgen.analysis.chemenv.connectivity.connected_components import ConnectedComponent from pymatgen.analysis.chemenv.connectivity.connectivity_finder import ConnectivityFinder from pymatgen.analysis.chemenv.connectivity.environment_nodes import EnvironmentNode diff --git a/tests/analysis/chemenv/coordination_environments/test_chemenv_strategies.py b/tests/analysis/chemenv/coordination_environments/test_chemenv_strategies.py index ef2109769e5..631aed31b01 100644 --- a/tests/analysis/chemenv/coordination_environments/test_chemenv_strategies.py +++ b/tests/analysis/chemenv/coordination_environments/test_chemenv_strategies.py @@ -1,6 +1,8 @@ from __future__ import annotations import pytest +from pytest import approx + from pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies import ( AdditionalConditionInt, AngleCutoffFloat, @@ -9,7 +11,6 @@ SimplestChemenvStrategy, ) from pymatgen.util.testing import PymatgenTest -from pytest import approx __author__ = "waroquiers" diff --git a/tests/analysis/chemenv/coordination_environments/test_coordination_geometries.py b/tests/analysis/chemenv/coordination_environments/test_coordination_geometries.py index 03a323c65e9..3cbda25a5fe 100644 --- a/tests/analysis/chemenv/coordination_environments/test_coordination_geometries.py +++ b/tests/analysis/chemenv/coordination_environments/test_coordination_geometries.py @@ -3,6 +3,8 @@ import numpy as np import pytest from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import ( AllCoordinationGeometries, CoordinationGeometry, @@ -10,7 +12,6 @@ SeparationPlane, ) from pymatgen.util.testing import PymatgenTest -from pytest import approx __author__ = "waroquiers" diff --git a/tests/analysis/chemenv/coordination_environments/test_coordination_geometry_finder.py b/tests/analysis/chemenv/coordination_environments/test_coordination_geometry_finder.py index 2428253b876..fc26a3c33af 100644 --- a/tests/analysis/chemenv/coordination_environments/test_coordination_geometry_finder.py +++ b/tests/analysis/chemenv/coordination_environments/test_coordination_geometry_finder.py @@ -3,6 +3,8 @@ import numpy as np import pytest from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import AllCoordinationGeometries from pymatgen.analysis.chemenv.coordination_environments.coordination_geometry_finder import ( AbstractGeometry, @@ -11,7 +13,6 @@ ) from pymatgen.core.structure import Lattice, Structure from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx __author__ = "waroquiers" diff --git a/tests/analysis/chemenv/coordination_environments/test_read_write.py b/tests/analysis/chemenv/coordination_environments/test_read_write.py index 0bb61b6163a..42ee8b8cb91 100644 --- a/tests/analysis/chemenv/coordination_environments/test_read_write.py +++ b/tests/analysis/chemenv/coordination_environments/test_read_write.py @@ -3,6 +3,8 @@ import json from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies import ( AngleNbSetWeight, CNBiasNbSetWeight, @@ -21,7 +23,6 @@ from pymatgen.analysis.chemenv.coordination_environments.voronoi import DetailedVoronoiContainer from pymatgen.core.structure import Structure from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx __author__ = "waroquiers" diff --git a/tests/analysis/chemenv/coordination_environments/test_structure_environments.py b/tests/analysis/chemenv/coordination_environments/test_structure_environments.py index 8ce3f92ec4b..b9a8ec160d7 100644 --- a/tests/analysis/chemenv/coordination_environments/test_structure_environments.py +++ b/tests/analysis/chemenv/coordination_environments/test_structure_environments.py @@ -5,6 +5,8 @@ import numpy as np from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies import ( MultiWeightsChemenvStrategy, SimplestChemenvStrategy, @@ -16,7 +18,6 @@ ) from pymatgen.core import Species, Structure from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx __author__ = "waroquiers" diff --git a/tests/analysis/chemenv/coordination_environments/test_voronoi.py b/tests/analysis/chemenv/coordination_environments/test_voronoi.py index 2adaa1f343c..cfe7b6af420 100644 --- a/tests/analysis/chemenv/coordination_environments/test_voronoi.py +++ b/tests/analysis/chemenv/coordination_environments/test_voronoi.py @@ -3,6 +3,7 @@ import random import numpy as np + from pymatgen.analysis.chemenv.coordination_environments.voronoi import DetailedVoronoiContainer from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure diff --git a/tests/analysis/chemenv/coordination_environments/test_weights.py b/tests/analysis/chemenv/coordination_environments/test_weights.py index 5295d47c635..f4f117dbe38 100644 --- a/tests/analysis/chemenv/coordination_environments/test_weights.py +++ b/tests/analysis/chemenv/coordination_environments/test_weights.py @@ -3,6 +3,8 @@ import json import pytest +from pytest import approx + from pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies import ( AngleNbSetWeight, CNBiasNbSetWeight, @@ -15,7 +17,6 @@ ) from pymatgen.analysis.chemenv.coordination_environments.structure_environments import StructureEnvironments from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx __author__ = "waroquiers" diff --git a/tests/analysis/chemenv/utils/test_coordination_geometry_utils.py b/tests/analysis/chemenv/utils/test_coordination_geometry_utils.py index 7124904f7cd..10e8ff8eb2e 100644 --- a/tests/analysis/chemenv/utils/test_coordination_geometry_utils.py +++ b/tests/analysis/chemenv/utils/test_coordination_geometry_utils.py @@ -5,9 +5,10 @@ import numpy as np from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.chemenv.utils.coordination_geometry_utils import Plane from pymatgen.util.testing import PymatgenTest -from pytest import approx __author__ = "David Waroquiers" diff --git a/tests/analysis/chemenv/utils/test_func_utils.py b/tests/analysis/chemenv/utils/test_func_utils.py index e01c3d66cc8..265c26d39f4 100644 --- a/tests/analysis/chemenv/utils/test_func_utils.py +++ b/tests/analysis/chemenv/utils/test_func_utils.py @@ -2,12 +2,13 @@ import numpy as np import pytest +from pytest import approx + from pymatgen.analysis.chemenv.utils.func_utils import ( CSMFiniteRatioFunction, CSMInfiniteRatioFunction, DeltaCSMRatioFunction, ) -from pytest import approx __author__ = "waroquiers" diff --git a/tests/analysis/chemenv/utils/test_graph_utils.py b/tests/analysis/chemenv/utils/test_graph_utils.py index cf7ef01fa30..54ca8e9ef08 100644 --- a/tests/analysis/chemenv/utils/test_graph_utils.py +++ b/tests/analysis/chemenv/utils/test_graph_utils.py @@ -2,6 +2,7 @@ import pytest from numpy.testing import assert_allclose + from pymatgen.analysis.chemenv.connectivity.environment_nodes import EnvironmentNode from pymatgen.analysis.chemenv.utils.graph_utils import MultiGraphCycle, SimpleGraphCycle, get_delta from pymatgen.util.testing import PymatgenTest diff --git a/tests/analysis/chemenv/utils/test_math_utils.py b/tests/analysis/chemenv/utils/test_math_utils.py index 3b0cab7d229..87420c9c61e 100644 --- a/tests/analysis/chemenv/utils/test_math_utils.py +++ b/tests/analysis/chemenv/utils/test_math_utils.py @@ -2,6 +2,7 @@ import numpy as np from numpy.testing import assert_allclose + from pymatgen.analysis.chemenv.utils.math_utils import ( _cartesian_product, cosinus_step, diff --git a/tests/analysis/diffraction/test_neutron.py b/tests/analysis/diffraction/test_neutron.py index 5256710bae1..f9f54d9d4fa 100644 --- a/tests/analysis/diffraction/test_neutron.py +++ b/tests/analysis/diffraction/test_neutron.py @@ -1,11 +1,12 @@ from __future__ import annotations import pytest +from pytest import approx + from pymatgen.analysis.diffraction.neutron import NDCalculator from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.util.testing import PymatgenTest -from pytest import approx """ These calculated values were verified with VESTA and FullProf. diff --git a/tests/analysis/diffraction/test_tem.py b/tests/analysis/diffraction/test_tem.py index edbe77256ca..7b5a79cea67 100644 --- a/tests/analysis/diffraction/test_tem.py +++ b/tests/analysis/diffraction/test_tem.py @@ -6,11 +6,12 @@ import pandas as pd import plotly.graph_objects as go from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.diffraction.tem import TEMCalculator from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.util.testing import PymatgenTest -from pytest import approx __author__ = "Frank Wan, Jason Liang" __copyright__ = "Copyright 2019, The Materials Project" diff --git a/tests/analysis/diffraction/test_xrd.py b/tests/analysis/diffraction/test_xrd.py index ed4f9bcb2d2..9663d6fbf7d 100644 --- a/tests/analysis/diffraction/test_xrd.py +++ b/tests/analysis/diffraction/test_xrd.py @@ -1,11 +1,12 @@ from __future__ import annotations import pytest +from pytest import approx + from pymatgen.analysis.diffraction.xrd import XRDCalculator from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.util.testing import PymatgenTest -from pytest import approx """ TODO: Modify unittest doc. diff --git a/tests/analysis/elasticity/test_elastic.py b/tests/analysis/elasticity/test_elastic.py index 85de3ac4728..4fe8ecdc5da 100644 --- a/tests/analysis/elasticity/test_elastic.py +++ b/tests/analysis/elasticity/test_elastic.py @@ -8,6 +8,9 @@ import numpy as np import pytest from numpy.testing import assert_allclose +from pytest import approx +from scipy.misc import central_diff_weights + from pymatgen.analysis.elasticity.elastic import ( ComplianceTensor, ElasticTensor, @@ -26,8 +29,6 @@ from pymatgen.core.tensors import Tensor from pymatgen.core.units import FloatWithUnit from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx -from scipy.misc import central_diff_weights TEST_DIR = f"{TEST_FILES_DIR}/analysis/elasticity" diff --git a/tests/analysis/elasticity/test_strain.py b/tests/analysis/elasticity/test_strain.py index 2ffadf975e5..e64de89f18d 100644 --- a/tests/analysis/elasticity/test_strain.py +++ b/tests/analysis/elasticity/test_strain.py @@ -3,6 +3,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose + from pymatgen.analysis.elasticity.strain import Deformation, DeformedStructureSet, Strain, convert_strain_to_deformation from pymatgen.core.structure import Structure from pymatgen.core.tensors import Tensor diff --git a/tests/analysis/elasticity/test_stress.py b/tests/analysis/elasticity/test_stress.py index 66a656243ed..cc79322de83 100644 --- a/tests/analysis/elasticity/test_stress.py +++ b/tests/analysis/elasticity/test_stress.py @@ -3,10 +3,11 @@ import numpy as np import pytest from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.elasticity.strain import Deformation from pymatgen.analysis.elasticity.stress import Stress from pymatgen.util.testing import PymatgenTest -from pytest import approx class TestStress(PymatgenTest): diff --git a/tests/analysis/ferroelectricity/test_polarization.py b/tests/analysis/ferroelectricity/test_polarization.py index 67f90933990..8c5de6645fc 100644 --- a/tests/analysis/ferroelectricity/test_polarization.py +++ b/tests/analysis/ferroelectricity/test_polarization.py @@ -2,6 +2,8 @@ import numpy as np from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.ferroelectricity.polarization import ( EnergyTrend, Polarization, @@ -12,7 +14,6 @@ from pymatgen.io.vasp.inputs import Potcar from pymatgen.io.vasp.outputs import Outcar from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/io/vasp/fixtures/BTO_221_99_polarization" bto_folders = ["nonpolar_polarization"] diff --git a/tests/analysis/interfaces/test_coherent_interface.py b/tests/analysis/interfaces/test_coherent_interface.py index 1284bc8c731..081cc3c4b62 100644 --- a/tests/analysis/interfaces/test_coherent_interface.py +++ b/tests/analysis/interfaces/test_coherent_interface.py @@ -1,6 +1,7 @@ from __future__ import annotations from numpy.testing import assert_allclose + from pymatgen.analysis.interfaces.coherent_interfaces import ( CoherentInterfaceBuilder, from_2d_to_3d, diff --git a/tests/analysis/interfaces/test_substrate_analyzer.py b/tests/analysis/interfaces/test_substrate_analyzer.py index 39e75ea53f5..a842cd4dad7 100644 --- a/tests/analysis/interfaces/test_substrate_analyzer.py +++ b/tests/analysis/interfaces/test_substrate_analyzer.py @@ -1,6 +1,7 @@ from __future__ import annotations from numpy.testing import assert_allclose + from pymatgen.analysis.elasticity.elastic import ElasticTensor from pymatgen.analysis.interfaces.substrate_analyzer import SubstrateAnalyzer from pymatgen.symmetry.analyzer import SpacegroupAnalyzer diff --git a/tests/analysis/interfaces/test_zsl.py b/tests/analysis/interfaces/test_zsl.py index d4fc0bdef2a..3cc7732eb73 100644 --- a/tests/analysis/interfaces/test_zsl.py +++ b/tests/analysis/interfaces/test_zsl.py @@ -2,6 +2,8 @@ import numpy as np from numpy.testing import assert_array_equal +from pytest import approx + from pymatgen.analysis.interfaces.zsl import ( ZSLGenerator, fast_norm, @@ -12,7 +14,6 @@ ) from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.testing import PymatgenTest -from pytest import approx __author__ = "Shyam Dwaraknath" __copyright__ = "Copyright 2016, The Materials Project" diff --git a/tests/analysis/magnetism/test_analyzer.py b/tests/analysis/magnetism/test_analyzer.py index 12e0f3029a6..bcdd02f1970 100644 --- a/tests/analysis/magnetism/test_analyzer.py +++ b/tests/analysis/magnetism/test_analyzer.py @@ -6,6 +6,8 @@ import pytest from monty.serialization import loadfn from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.magnetism import ( CollinearMagneticStructureAnalyzer, MagneticStructureEnumerator, @@ -14,7 +16,6 @@ ) from pymatgen.core import Element, Lattice, Species, Structure from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/magnetic_orderings" diff --git a/tests/analysis/magnetism/test_heisenberg.py b/tests/analysis/magnetism/test_heisenberg.py index 968e28524ce..3eea3bd6782 100644 --- a/tests/analysis/magnetism/test_heisenberg.py +++ b/tests/analysis/magnetism/test_heisenberg.py @@ -3,6 +3,7 @@ from unittest import TestCase import pandas as pd + from pymatgen.analysis.magnetism.heisenberg import HeisenbergMapper from pymatgen.core.structure import Structure from pymatgen.util.testing import TEST_FILES_DIR diff --git a/tests/analysis/magnetism/test_jahnteller.py b/tests/analysis/magnetism/test_jahnteller.py index 3a5da6a5ef4..6cc3356b4aa 100644 --- a/tests/analysis/magnetism/test_jahnteller.py +++ b/tests/analysis/magnetism/test_jahnteller.py @@ -3,10 +3,11 @@ from unittest import TestCase import numpy as np +from pytest import approx + from pymatgen.analysis.magnetism.jahnteller import JahnTellerAnalyzer, Species from pymatgen.core import Structure from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx class TestJahnTeller(TestCase): diff --git a/tests/analysis/solar/test_slme.py b/tests/analysis/solar/test_slme.py index 906dba63bc7..4d2e12c1ef0 100644 --- a/tests/analysis/solar/test_slme.py +++ b/tests/analysis/solar/test_slme.py @@ -1,8 +1,9 @@ from __future__ import annotations +from pytest import approx + from pymatgen.analysis.solar.slme import optics, slme from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/solar" diff --git a/tests/analysis/structure_prediction/test_dopant_predictor.py b/tests/analysis/structure_prediction/test_dopant_predictor.py index a763421b0bb..f19d032624d 100644 --- a/tests/analysis/structure_prediction/test_dopant_predictor.py +++ b/tests/analysis/structure_prediction/test_dopant_predictor.py @@ -2,13 +2,14 @@ from unittest import TestCase +from pytest import approx + from pymatgen.analysis.local_env import CrystalNN from pymatgen.analysis.structure_prediction.dopant_predictor import ( get_dopants_from_shannon_radii, get_dopants_from_substitution_probabilities, ) from pymatgen.core import Species, Structure -from pytest import approx class TestDopantPrediction(TestCase): diff --git a/tests/analysis/structure_prediction/test_substitution_probability.py b/tests/analysis/structure_prediction/test_substitution_probability.py index eb9115995a3..e6c5f9786d0 100644 --- a/tests/analysis/structure_prediction/test_substitution_probability.py +++ b/tests/analysis/structure_prediction/test_substitution_probability.py @@ -3,13 +3,14 @@ import json from unittest import TestCase +from pytest import approx + from pymatgen.analysis.structure_prediction.substitution_probability import ( SubstitutionPredictor, SubstitutionProbability, ) from pymatgen.core import Composition, Species from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/struct_predictor" diff --git a/tests/analysis/structure_prediction/test_volume_predictor.py b/tests/analysis/structure_prediction/test_volume_predictor.py index 069a9dbc86f..9f6a150aeb7 100644 --- a/tests/analysis/structure_prediction/test_volume_predictor.py +++ b/tests/analysis/structure_prediction/test_volume_predictor.py @@ -1,10 +1,11 @@ from __future__ import annotations import pytest +from pytest import approx + from pymatgen.analysis.structure_prediction.volume_predictor import DLSVolumePredictor, RLSVolumePredictor from pymatgen.core import Structure from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/structure_prediction" diff --git a/tests/analysis/test_adsorption.py b/tests/analysis/test_adsorption.py index 76fdc09a0cd..9f611a2feaa 100644 --- a/tests/analysis/test_adsorption.py +++ b/tests/analysis/test_adsorption.py @@ -2,6 +2,7 @@ import numpy as np from numpy.testing import assert_allclose + from pymatgen.analysis.adsorption import AdsorbateSiteFinder, generate_all_slabs, get_rot, reorient_z from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Molecule, Structure diff --git a/tests/analysis/test_bond_dissociation.py b/tests/analysis/test_bond_dissociation.py index 6dd0d7f9af6..b29081413c9 100644 --- a/tests/analysis/test_bond_dissociation.py +++ b/tests/analysis/test_bond_dissociation.py @@ -4,6 +4,7 @@ import pytest from monty.serialization import loadfn + from pymatgen.analysis.bond_dissociation import BondDissociationEnergies from pymatgen.util.testing import TEST_FILES_DIR diff --git a/tests/analysis/test_bond_valence.py b/tests/analysis/test_bond_valence.py index 5a0202e075b..8bfc158a574 100644 --- a/tests/analysis/test_bond_valence.py +++ b/tests/analysis/test_bond_valence.py @@ -1,10 +1,11 @@ from __future__ import annotations import pytest +from pytest import approx + from pymatgen.analysis.bond_valence import BVAnalyzer, calculate_bv_sum, calculate_bv_sum_unordered from pymatgen.core import Composition, Species, Structure from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/bond_valence" diff --git a/tests/analysis/test_chempot_diagram.py b/tests/analysis/test_chempot_diagram.py index 5465e1d050d..648d6a5a164 100644 --- a/tests/analysis/test_chempot_diagram.py +++ b/tests/analysis/test_chempot_diagram.py @@ -2,6 +2,8 @@ import numpy as np from plotly.graph_objects import Figure +from pytest import approx + from pymatgen.analysis.chempot_diagram import ( ChemicalPotentialDiagram, get_2d_orthonormal_vector, @@ -11,7 +13,6 @@ from pymatgen.core.composition import Element from pymatgen.entries.entry_tools import EntrySet from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis" diff --git a/tests/analysis/test_cost.py b/tests/analysis/test_cost.py index 4aa598bc5fa..c20bed2fd54 100644 --- a/tests/analysis/test_cost.py +++ b/tests/analysis/test_cost.py @@ -2,9 +2,10 @@ from unittest import TestCase +from pytest import approx + from pymatgen.analysis.cost import CostAnalyzer, CostDBCSV, CostDBElements from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/cost" diff --git a/tests/analysis/test_dimensionality.py b/tests/analysis/test_dimensionality.py index b83c2cb5748..8b99c6fd5e2 100644 --- a/tests/analysis/test_dimensionality.py +++ b/tests/analysis/test_dimensionality.py @@ -3,6 +3,7 @@ import networkx as nx import pytest from monty.serialization import loadfn + from pymatgen.analysis.dimensionality import ( calculate_dimensionality_of_site, get_dimensionality_cheon, diff --git a/tests/analysis/test_disorder.py b/tests/analysis/test_disorder.py index 2384bc4e296..a4b930096ac 100644 --- a/tests/analysis/test_disorder.py +++ b/tests/analysis/test_disorder.py @@ -1,9 +1,10 @@ from __future__ import annotations +from pytest import approx + from pymatgen.analysis.disorder import get_warren_cowley_parameters from pymatgen.core import Element, Structure from pymatgen.util.testing import PymatgenTest -from pytest import approx class TestOrderParameter(PymatgenTest): diff --git a/tests/analysis/test_energy_models.py b/tests/analysis/test_energy_models.py index a2c4aa40612..36d3024ac75 100644 --- a/tests/analysis/test_energy_models.py +++ b/tests/analysis/test_energy_models.py @@ -1,11 +1,12 @@ from __future__ import annotations +from pytest import approx + from pymatgen.analysis.energy_models import EwaldElectrostaticModel, IsingModel, SymmetryModel from pymatgen.core import Species from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx class TestEwaldElectrostaticModel: diff --git a/tests/analysis/test_eos.py b/tests/analysis/test_eos.py index f31c3723eb7..4c02d040fd4 100644 --- a/tests/analysis/test_eos.py +++ b/tests/analysis/test_eos.py @@ -2,9 +2,10 @@ import numpy as np from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.eos import EOS, NumericalEOS from pymatgen.util.testing import PymatgenTest -from pytest import approx class TestEOS(PymatgenTest): diff --git a/tests/analysis/test_ewald.py b/tests/analysis/test_ewald.py index 7ada2e539dc..285152bb8fd 100644 --- a/tests/analysis/test_ewald.py +++ b/tests/analysis/test_ewald.py @@ -4,10 +4,11 @@ import numpy as np import pytest +from pytest import approx + from pymatgen.analysis.ewald import EwaldMinimizer, EwaldSummation from pymatgen.core.structure import Structure from pymatgen.util.testing import VASP_IN_DIR -from pytest import approx class TestEwaldSummation(TestCase): diff --git a/tests/analysis/test_fragmenter.py b/tests/analysis/test_fragmenter.py index 26b2840b3ae..611edcf58dd 100644 --- a/tests/analysis/test_fragmenter.py +++ b/tests/analysis/test_fragmenter.py @@ -1,6 +1,7 @@ from __future__ import annotations import pytest + from pymatgen.analysis.fragmenter import Fragmenter from pymatgen.analysis.graphs import MoleculeGraph from pymatgen.analysis.local_env import OpenBabelNN diff --git a/tests/analysis/test_functional_groups.py b/tests/analysis/test_functional_groups.py index bc59a7da57d..e53a62960a0 100644 --- a/tests/analysis/test_functional_groups.py +++ b/tests/analysis/test_functional_groups.py @@ -3,6 +3,7 @@ from unittest import TestCase import pytest + from pymatgen.analysis.functional_groups import FunctionalGroupExtractor from pymatgen.analysis.graphs import MoleculeGraph from pymatgen.analysis.local_env import OpenBabelNN diff --git a/tests/analysis/test_graphs.py b/tests/analysis/test_graphs.py index f196cde29ad..dcb8809a818 100644 --- a/tests/analysis/test_graphs.py +++ b/tests/analysis/test_graphs.py @@ -10,6 +10,8 @@ import networkx.algorithms.isomorphism as iso import pytest from monty.serialization import loadfn +from pytest import approx + from pymatgen.analysis.graphs import MoleculeGraph, MolGraphSplitError, PeriodicSite, StructureGraph from pymatgen.analysis.local_env import ( CovalentBondNN, @@ -23,7 +25,6 @@ from pymatgen.core import Lattice, Molecule, Site, Structure from pymatgen.core.structure import FunctionalGroups from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx try: from openbabel import openbabel diff --git a/tests/analysis/test_hhi.py b/tests/analysis/test_hhi.py index d1c95587124..105072426fb 100644 --- a/tests/analysis/test_hhi.py +++ b/tests/analysis/test_hhi.py @@ -1,8 +1,9 @@ from __future__ import annotations -from pymatgen.analysis.hhi import HHIModel from pytest import approx +from pymatgen.analysis.hhi import HHIModel + class TestHHIModel: def test_hhi(self): diff --git a/tests/analysis/test_interface_reactions.py b/tests/analysis/test_interface_reactions.py index 0b9665fef4f..3c47a6f9f3c 100644 --- a/tests/analysis/test_interface_reactions.py +++ b/tests/analysis/test_interface_reactions.py @@ -8,12 +8,13 @@ from numpy.testing import assert_allclose from pandas import DataFrame from plotly.graph_objects import Figure +from scipy.spatial import ConvexHull + from pymatgen.analysis.interface_reactions import GrandPotentialInterfacialReactivity, InterfacialReactivity from pymatgen.analysis.phase_diagram import GrandPotentialPhaseDiagram, PhaseDiagram from pymatgen.analysis.reaction_calculator import Reaction from pymatgen.core.composition import Composition, Element from pymatgen.entries.computed_entries import ComputedEntry -from scipy.spatial import ConvexHull class TestInterfaceReaction(TestCase): diff --git a/tests/analysis/test_local_env.py b/tests/analysis/test_local_env.py index 1fbed74da82..ed8b72c677d 100644 --- a/tests/analysis/test_local_env.py +++ b/tests/analysis/test_local_env.py @@ -7,6 +7,8 @@ import numpy as np import pytest from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.graphs import MoleculeGraph, StructureGraph from pymatgen.analysis.local_env import ( BrunnerNNReal, @@ -36,7 +38,6 @@ ) from pymatgen.core import Element, Lattice, Molecule, Structure from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/local_env/fragmenter_files" diff --git a/tests/analysis/test_molecule_matcher.py b/tests/analysis/test_molecule_matcher.py index cca70ae1c2c..485e3c75f2f 100644 --- a/tests/analysis/test_molecule_matcher.py +++ b/tests/analysis/test_molecule_matcher.py @@ -4,6 +4,8 @@ import numpy as np import pytest +from pytest import approx + from pymatgen.analysis.molecule_matcher import ( BruteForceOrderMatcher, GeneticOrderMatcher, @@ -17,7 +19,6 @@ from pymatgen.core.structure import Lattice, Molecule, Structure from pymatgen.io.xyz import XYZ from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx try: from openbabel import openbabel diff --git a/tests/analysis/test_nmr.py b/tests/analysis/test_nmr.py index 86961996a71..14490ec7a0c 100644 --- a/tests/analysis/test_nmr.py +++ b/tests/analysis/test_nmr.py @@ -2,9 +2,10 @@ import numpy as np from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.analysis.nmr import ChemicalShielding, ElectricFieldGradient from pymatgen.util.testing import PymatgenTest -from pytest import approx class TestChemicalShieldingNotation(PymatgenTest): diff --git a/tests/analysis/test_phase_diagram.py b/tests/analysis/test_phase_diagram.py index 997a7cd0bac..4e1e2dfb3f1 100644 --- a/tests/analysis/test_phase_diagram.py +++ b/tests/analysis/test_phase_diagram.py @@ -13,6 +13,8 @@ import pytest from monty.serialization import dumpfn, loadfn from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.phase_diagram import ( CompoundPhaseDiagram, GrandPotentialPhaseDiagram, @@ -31,7 +33,6 @@ from pymatgen.entries.computed_entries import ComputedEntry from pymatgen.entries.entry_tools import EntrySet from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis" diff --git a/tests/analysis/test_piezo.py b/tests/analysis/test_piezo.py index 0bd01459e6f..bf3eb7534c2 100644 --- a/tests/analysis/test_piezo.py +++ b/tests/analysis/test_piezo.py @@ -5,6 +5,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal + from pymatgen.analysis.piezo import PiezoTensor from pymatgen.util.testing import PymatgenTest diff --git a/tests/analysis/test_piezo_sensitivity.py b/tests/analysis/test_piezo_sensitivity.py index 19f2444f028..eafaaddc6b4 100644 --- a/tests/analysis/test_piezo_sensitivity.py +++ b/tests/analysis/test_piezo_sensitivity.py @@ -5,9 +5,10 @@ import pickle import numpy as np -import pymatgen import pytest from numpy.testing import assert_allclose + +import pymatgen from pymatgen.analysis.piezo_sensitivity import ( BornEffectiveCharge, ForceConstantMatrix, diff --git a/tests/analysis/test_pourbaix_diagram.py b/tests/analysis/test_pourbaix_diagram.py index 6ea90a801b3..3119877f33b 100644 --- a/tests/analysis/test_pourbaix_diagram.py +++ b/tests/analysis/test_pourbaix_diagram.py @@ -7,12 +7,13 @@ import matplotlib.pyplot as plt import numpy as np from monty.serialization import dumpfn, loadfn +from pytest import approx + from pymatgen.analysis.pourbaix_diagram import IonEntry, MultiEntry, PourbaixDiagram, PourbaixEntry, PourbaixPlotter from pymatgen.core.composition import Composition from pymatgen.core.ion import Ion from pymatgen.entries.computed_entries import ComputedEntry from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/pourbaix_diagram" diff --git a/tests/analysis/test_quasi_harmonic_debye_approx.py b/tests/analysis/test_quasi_harmonic_debye_approx.py index fce94e37d44..9a9aa86bce5 100644 --- a/tests/analysis/test_quasi_harmonic_debye_approx.py +++ b/tests/analysis/test_quasi_harmonic_debye_approx.py @@ -4,6 +4,7 @@ import numpy as np from numpy.testing import assert_allclose + from pymatgen.analysis.eos import EOS from pymatgen.analysis.quasiharmonic import QuasiHarmonicDebyeApprox from pymatgen.core.structure import Structure diff --git a/tests/analysis/test_quasirrho.py b/tests/analysis/test_quasirrho.py index 37829e37a75..63cd0015ad4 100644 --- a/tests/analysis/test_quasirrho.py +++ b/tests/analysis/test_quasirrho.py @@ -3,6 +3,7 @@ from unittest import TestCase import pytest + from pymatgen.analysis.quasirrho import QuasiRRHO, get_avg_mom_inertia from pymatgen.io.gaussian import GaussianOutput from pymatgen.io.qchem.outputs import QCOutput diff --git a/tests/analysis/test_reaction_calculator.py b/tests/analysis/test_reaction_calculator.py index f8584fd5549..dcb06819574 100644 --- a/tests/analysis/test_reaction_calculator.py +++ b/tests/analysis/test_reaction_calculator.py @@ -6,10 +6,11 @@ import numpy as np import pytest +from pytest import approx + from pymatgen.analysis.reaction_calculator import BalancedReaction, ComputedReaction, Reaction, ReactionError from pymatgen.core.composition import Composition from pymatgen.entries.computed_entries import ComputedEntry -from pytest import approx class TestReaction: diff --git a/tests/analysis/test_structure_analyzer.py b/tests/analysis/test_structure_analyzer.py index 1639729a56a..12a0c02f991 100644 --- a/tests/analysis/test_structure_analyzer.py +++ b/tests/analysis/test_structure_analyzer.py @@ -4,6 +4,8 @@ import numpy as np from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.structure_analyzer import ( RelaxationAnalyzer, VoronoiAnalyzer, @@ -17,7 +19,6 @@ from pymatgen.core import Element, Lattice, Structure from pymatgen.io.vasp.outputs import Xdatcar from pymatgen.util.testing import VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest -from pytest import approx class TestVoronoiAnalyzer(PymatgenTest): diff --git a/tests/analysis/test_structure_matcher.py b/tests/analysis/test_structure_matcher.py index 28707ef44de..c658585cf75 100644 --- a/tests/analysis/test_structure_matcher.py +++ b/tests/analysis/test_structure_matcher.py @@ -6,6 +6,8 @@ import pytest from monty.json import MontyDecoder from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.analysis.structure_matcher import ( ElementComparator, FrameworkComparator, @@ -16,7 +18,6 @@ from pymatgen.core import Element, Lattice, Structure, SymmOp from pymatgen.util.coord import find_in_coord_list_pbc from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/structure_matcher" diff --git a/tests/analysis/test_surface_analysis.py b/tests/analysis/test_surface_analysis.py index 07195437d80..0e58a2099d5 100644 --- a/tests/analysis/test_surface_analysis.py +++ b/tests/analysis/test_surface_analysis.py @@ -3,11 +3,12 @@ import json from numpy.testing import assert_allclose +from pytest import approx +from sympy import Number, Symbol + from pymatgen.analysis.surface_analysis import NanoscaleStability, SlabEntry, SurfaceEnergyPlotter, WorkFunctionAnalyzer from pymatgen.entries.computed_entries import ComputedStructureEntry from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx -from sympy import Number, Symbol __author__ = "Richard Tran" __copyright__ = "Copyright 2012, The Materials Project" diff --git a/tests/analysis/test_transition_state.py b/tests/analysis/test_transition_state.py index 0e404e02fc8..96841bc482a 100644 --- a/tests/analysis/test_transition_state.py +++ b/tests/analysis/test_transition_state.py @@ -4,6 +4,7 @@ from matplotlib import pyplot as plt from numpy.testing import assert_allclose + from pymatgen.analysis.transition_state import NEBAnalysis, combine_neb_plots from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest diff --git a/tests/analysis/test_wulff.py b/tests/analysis/test_wulff.py index c4656a79097..11109c1e746 100644 --- a/tests/analysis/test_wulff.py +++ b/tests/analysis/test_wulff.py @@ -2,13 +2,14 @@ import json +from pytest import approx + from pymatgen.analysis.wulff import WulffShape from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.coord import in_coord_list from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx __author__ = "Zihan Xu, Richard Tran, Balachandran Radhakrishnan" __copyright__ = "Copyright 2013, The Materials Virtual Lab" diff --git a/tests/analysis/topological/test_spillage.py b/tests/analysis/topological/test_spillage.py index 61652c97696..39224cdfc52 100644 --- a/tests/analysis/topological/test_spillage.py +++ b/tests/analysis/topological/test_spillage.py @@ -1,8 +1,9 @@ from __future__ import annotations +from pytest import approx + from pymatgen.analysis.topological.spillage import SOCSpillage from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/topological" diff --git a/tests/analysis/xas/test_spectrum.py b/tests/analysis/xas/test_spectrum.py index 25772d15fb7..ccc1c3812a5 100644 --- a/tests/analysis/xas/test_spectrum.py +++ b/tests/analysis/xas/test_spectrum.py @@ -6,10 +6,11 @@ import pytest from monty.json import MontyDecoder from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.analysis.xas.spectrum import XAS, site_weighted_spectrum from pymatgen.core import Element from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/spectrum_test" diff --git a/tests/apps/battery/test_analyzer.py b/tests/apps/battery/test_analyzer.py index a7a22ccf015..61426c65510 100644 --- a/tests/apps/battery/test_analyzer.py +++ b/tests/apps/battery/test_analyzer.py @@ -1,10 +1,11 @@ from __future__ import annotations import pytest +from pytest import approx + from pymatgen.apps.battery.analyzer import BatteryAnalyzer from pymatgen.core.structure import Structure from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx class TestBatteryAnalyzer(PymatgenTest): diff --git a/tests/apps/battery/test_conversion_battery.py b/tests/apps/battery/test_conversion_battery.py index 041702625a4..ae17c969353 100644 --- a/tests/apps/battery/test_conversion_battery.py +++ b/tests/apps/battery/test_conversion_battery.py @@ -4,10 +4,11 @@ from unittest import TestCase from monty.json import MontyDecoder +from pytest import approx + from pymatgen.apps.battery.conversion_battery import ConversionElectrode, ConversionVoltagePair from pymatgen.core.composition import Composition from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/apps/battery" diff --git a/tests/apps/battery/test_insertion_battery.py b/tests/apps/battery/test_insertion_battery.py index 06c6ef0802f..4c6b9caa951 100644 --- a/tests/apps/battery/test_insertion_battery.py +++ b/tests/apps/battery/test_insertion_battery.py @@ -4,10 +4,11 @@ from unittest import TestCase from monty.json import MontyDecoder, MontyEncoder +from pytest import approx + from pymatgen.apps.battery.insertion_battery import InsertionElectrode, InsertionVoltagePair from pymatgen.entries.computed_entries import ComputedEntry from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/apps/battery" diff --git a/tests/apps/battery/test_plotter.py b/tests/apps/battery/test_plotter.py index c9e14875e25..8b93b20f8bf 100644 --- a/tests/apps/battery/test_plotter.py +++ b/tests/apps/battery/test_plotter.py @@ -4,6 +4,7 @@ from unittest import TestCase from monty.json import MontyDecoder + from pymatgen.apps.battery.conversion_battery import ConversionElectrode from pymatgen.apps.battery.insertion_battery import InsertionElectrode from pymatgen.apps.battery.plotter import VoltageProfilePlotter diff --git a/tests/apps/borg/test_hive.py b/tests/apps/borg/test_hive.py index 64b64814c70..766086d429b 100644 --- a/tests/apps/borg/test_hive.py +++ b/tests/apps/borg/test_hive.py @@ -3,6 +3,8 @@ import os from unittest import TestCase +from pytest import approx + from pymatgen.apps.borg.hive import ( GaussianToComputedEntryDrone, SimpleVaspToComputedEntryDrone, @@ -10,7 +12,6 @@ ) from pymatgen.entries.computed_entries import ComputedStructureEntry from pymatgen.util.testing import TEST_FILES_DIR, VASP_OUT_DIR -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/apps/borg" diff --git a/tests/apps/borg/test_queen.py b/tests/apps/borg/test_queen.py index 14cc20679a9..b95e660f7f8 100644 --- a/tests/apps/borg/test_queen.py +++ b/tests/apps/borg/test_queen.py @@ -1,9 +1,10 @@ from __future__ import annotations +from pytest import approx + from pymatgen.apps.borg.hive import VaspToComputedEntryDrone from pymatgen.apps.borg.queen import BorgQueen from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx __author__ = "Shyue Ping Ong" __copyright__ = "Copyright 2012, The Materials Project" diff --git a/tests/command_line/test_bader_caller.py b/tests/command_line/test_bader_caller.py index 5bff1599c62..c3d9b609946 100644 --- a/tests/command_line/test_bader_caller.py +++ b/tests/command_line/test_bader_caller.py @@ -8,9 +8,10 @@ import pytest from monty.shutil import copy_r from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.command_line.bader_caller import BaderAnalysis, bader_analysis_from_path from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/command_line/bader" diff --git a/tests/command_line/test_critic2_caller.py b/tests/command_line/test_critic2_caller.py index 4f1a7cf648f..46218f94e8c 100644 --- a/tests/command_line/test_critic2_caller.py +++ b/tests/command_line/test_critic2_caller.py @@ -4,10 +4,11 @@ from unittest import TestCase import pytest +from pytest import approx + from pymatgen.command_line.critic2_caller import Critic2Analysis, Critic2Caller from pymatgen.core.structure import Structure from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx __author__ = "Matthew Horton" __version__ = "0.1" diff --git a/tests/command_line/test_enumlib_caller.py b/tests/command_line/test_enumlib_caller.py index d21b5b67986..010bb0bd1b8 100644 --- a/tests/command_line/test_enumlib_caller.py +++ b/tests/command_line/test_enumlib_caller.py @@ -5,13 +5,14 @@ import numpy as np import pytest +from pytest import approx + from pymatgen.command_line.enumlib_caller import EnumError, EnumlibAdaptor from pymatgen.core import Element, Structure from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.transformations.site_transformations import RemoveSitesTransformation from pymatgen.transformations.standard_transformations import SubstitutionTransformation from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx enum_cmd = which("enum.x") or which("multienum.x") makestr_cmd = which("makestr.x") or which("makeStr.x") or which("makeStr.py") diff --git a/tests/command_line/test_gulp_caller.py b/tests/command_line/test_gulp_caller.py index aa0faf1d16e..054d0e7c023 100644 --- a/tests/command_line/test_gulp_caller.py +++ b/tests/command_line/test_gulp_caller.py @@ -14,6 +14,7 @@ import numpy as np import pytest + from pymatgen.analysis.bond_valence import BVAnalyzer from pymatgen.command_line.gulp_caller import ( BuckinghamPotential, diff --git a/tests/command_line/test_mcsqs_caller.py b/tests/command_line/test_mcsqs_caller.py index 9dd6303a1dc..39714b1f4f1 100644 --- a/tests/command_line/test_mcsqs_caller.py +++ b/tests/command_line/test_mcsqs_caller.py @@ -4,6 +4,7 @@ import pytest from monty.serialization import loadfn + from pymatgen.command_line.mcsqs_caller import run_mcsqs from pymatgen.core.structure import Structure from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest diff --git a/tests/command_line/test_vampire_caller.py b/tests/command_line/test_vampire_caller.py index e8cc2330f02..19efe2eef1f 100644 --- a/tests/command_line/test_vampire_caller.py +++ b/tests/command_line/test_vampire_caller.py @@ -4,10 +4,11 @@ import pandas as pd import pytest +from pytest import approx + from pymatgen.command_line.vampire_caller import VampireCaller from pymatgen.core.structure import Structure from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/analysis/magnetic_orderings" diff --git a/tests/core/test_bonds.py b/tests/core/test_bonds.py index 9154207aba6..777d938619a 100644 --- a/tests/core/test_bonds.py +++ b/tests/core/test_bonds.py @@ -1,9 +1,10 @@ from __future__ import annotations import pytest +from pytest import approx + from pymatgen.core import Element, Site from pymatgen.core.bonds import CovalentBond, get_bond_length, get_bond_order, obtain_all_bond_lengths -from pytest import approx __author__ = "Shyue Ping Ong" __copyright__ = "Copyright 2012, The Materials Project" diff --git a/tests/core/test_composition.py b/tests/core/test_composition.py index 1cf2c688e31..f520438c15b 100644 --- a/tests/core/test_composition.py +++ b/tests/core/test_composition.py @@ -10,10 +10,11 @@ import pytest from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core import Composition, DummySpecies, Element, Species from pymatgen.core.composition import ChemicalPotential from pymatgen.util.testing import PymatgenTest -from pytest import approx class TestComposition(PymatgenTest): diff --git a/tests/core/test_interface.py b/tests/core/test_interface.py index 1757265fd27..22cd178dd5b 100644 --- a/tests/core/test_interface.py +++ b/tests/core/test_interface.py @@ -2,12 +2,13 @@ import numpy as np from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core.interface import GrainBoundary, GrainBoundaryGenerator, Interface from pymatgen.core.structure import Structure from pymatgen.core.surface import SlabGenerator from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/core/grain_boundary" diff --git a/tests/core/test_lattice.py b/tests/core/test_lattice.py index 91a84688039..ce5cff053aa 100644 --- a/tests/core/test_lattice.py +++ b/tests/core/test_lattice.py @@ -5,10 +5,11 @@ import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.core.lattice import Lattice, get_points_in_spheres from pymatgen.core.operations import SymmOp from pymatgen.util.testing import PymatgenTest -from pytest import approx class TestLattice(PymatgenTest): diff --git a/tests/core/test_molecular_orbitals.py b/tests/core/test_molecular_orbitals.py index a1699967585..4476c856d17 100644 --- a/tests/core/test_molecular_orbitals.py +++ b/tests/core/test_molecular_orbitals.py @@ -1,6 +1,7 @@ from __future__ import annotations import pytest + from pymatgen.core.molecular_orbitals import MolecularOrbitals from pymatgen.util.testing import PymatgenTest diff --git a/tests/core/test_operations.py b/tests/core/test_operations.py index abd9d4357a6..d2dcc26de42 100644 --- a/tests/core/test_operations.py +++ b/tests/core/test_operations.py @@ -2,6 +2,7 @@ import numpy as np from numpy.testing import assert_allclose + from pymatgen.core.operations import MagSymmOp, SymmOp from pymatgen.electronic_structure.core import Magmom from pymatgen.util.testing import PymatgenTest diff --git a/tests/core/test_periodic_table.py b/tests/core/test_periodic_table.py index f92335d5266..75e84a9932f 100644 --- a/tests/core/test_periodic_table.py +++ b/tests/core/test_periodic_table.py @@ -8,12 +8,13 @@ import numpy as np import pytest +from pytest import approx + from pymatgen.core import DummySpecies, Element, Species, get_el_sp from pymatgen.core.periodic_table import ElementBase, ElementType from pymatgen.core.units import Ha_to_eV from pymatgen.io.core import ParseError from pymatgen.util.testing import PymatgenTest -from pytest import approx class TestElement(PymatgenTest): diff --git a/tests/core/test_sites.py b/tests/core/test_sites.py index ee3911c29eb..a80689d9dfd 100644 --- a/tests/core/test_sites.py +++ b/tests/core/test_sites.py @@ -5,10 +5,11 @@ import numpy as np import pytest from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core import Composition, Element, Lattice, PeriodicSite, Site, Species from pymatgen.electronic_structure.core import Magmom from pymatgen.util.testing import PymatgenTest -from pytest import approx class TestSite(PymatgenTest): diff --git a/tests/core/test_spectrum.py b/tests/core/test_spectrum.py index 9f6fe473eba..86fb7e7266b 100644 --- a/tests/core/test_spectrum.py +++ b/tests/core/test_spectrum.py @@ -2,11 +2,12 @@ import numpy as np from numpy.testing import assert_allclose -from pymatgen.core.spectrum import Spectrum -from pymatgen.util.testing import PymatgenTest from pytest import approx from scipy import stats +from pymatgen.core.spectrum import Spectrum +from pymatgen.util.testing import PymatgenTest + class TestSpectrum(PymatgenTest): def setUp(self): diff --git a/tests/core/test_structure.py b/tests/core/test_structure.py index 20769d9cde0..6c0daa4a998 100644 --- a/tests/core/test_structure.py +++ b/tests/core/test_structure.py @@ -12,6 +12,8 @@ import pytest from monty.json import MontyDecoder, MontyEncoder from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.core import SETTINGS, Composition, Element, Lattice, Species from pymatgen.core.operations import SymmOp from pymatgen.core.structure import ( @@ -28,7 +30,6 @@ from pymatgen.io.cif import CifParser from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest -from pytest import approx try: from ase.atoms import Atoms diff --git a/tests/core/test_surface.py b/tests/core/test_surface.py index f910efdfa03..d27f46a77df 100644 --- a/tests/core/test_surface.py +++ b/tests/core/test_surface.py @@ -6,8 +6,10 @@ import unittest import numpy as np -import pymatgen from numpy.testing import assert_allclose +from pytest import approx + +import pymatgen from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core import Lattice, Structure from pymatgen.core.surface import ( @@ -24,7 +26,6 @@ from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.symmetry.groups import SpaceGroup from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx class TestSlab(PymatgenTest): diff --git a/tests/core/test_tensors.py b/tests/core/test_tensors.py index 0be6d488207..28548c3c3ba 100644 --- a/tests/core/test_tensors.py +++ b/tests/core/test_tensors.py @@ -6,11 +6,12 @@ import pytest from monty.serialization import MontyDecoder, loadfn from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core.operations import SymmOp from pymatgen.core.tensors import SquareTensor, Tensor, TensorCollection, TensorMapping, itertools, symmetry_reduce from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx class TestTensor(PymatgenTest): diff --git a/tests/core/test_trajectory.py b/tests/core/test_trajectory.py index f767412e7c8..444b476c66b 100644 --- a/tests/core/test_trajectory.py +++ b/tests/core/test_trajectory.py @@ -6,6 +6,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose + from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Molecule, Structure from pymatgen.core.trajectory import Trajectory diff --git a/tests/core/test_units.py b/tests/core/test_units.py index f2c2881b189..2abfd5df8f0 100644 --- a/tests/core/test_units.py +++ b/tests/core/test_units.py @@ -4,6 +4,8 @@ import pytest from numpy.testing import assert_array_equal +from pytest import approx + from pymatgen.core.units import ( ArrayWithUnit, Energy, @@ -25,7 +27,6 @@ unitized, ) from pymatgen.util.testing import PymatgenTest -from pytest import approx def test_unit_conversions(): diff --git a/tests/core/test_xcfunc.py b/tests/core/test_xcfunc.py index 8eba2c2dcc8..1cc64bbebc8 100644 --- a/tests/core/test_xcfunc.py +++ b/tests/core/test_xcfunc.py @@ -1,6 +1,7 @@ from __future__ import annotations import pytest + from pymatgen.core.xcfunc import XcFunc from pymatgen.util.testing import PymatgenTest diff --git a/tests/electronic_structure/test_bandstructure.py b/tests/electronic_structure/test_bandstructure.py index 0daa57fcab2..a6d9d9dfc41 100644 --- a/tests/electronic_structure/test_bandstructure.py +++ b/tests/electronic_structure/test_bandstructure.py @@ -8,6 +8,8 @@ import pytest from monty.serialization import loadfn from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core.lattice import Lattice from pymatgen.electronic_structure.bandstructure import ( BandStructureSymmLine, @@ -19,7 +21,6 @@ from pymatgen.electronic_structure.plotter import BSPlotterProjected from pymatgen.io.vasp import BSVasprun from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/bandstructure" diff --git a/tests/electronic_structure/test_boltztrap.py b/tests/electronic_structure/test_boltztrap.py index 8bdb69a5e19..4d1637dd56d 100644 --- a/tests/electronic_structure/test_boltztrap.py +++ b/tests/electronic_structure/test_boltztrap.py @@ -6,11 +6,12 @@ import pytest from monty.serialization import loadfn +from pytest import approx + from pymatgen.electronic_structure.bandstructure import BandStructure from pymatgen.electronic_structure.boltztrap import BoltztrapAnalyzer, BoltztrapRunner from pymatgen.electronic_structure.core import OrbitalType, Spin from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx try: from ase.io.cube import read_cube diff --git a/tests/electronic_structure/test_boltztrap2.py b/tests/electronic_structure/test_boltztrap2.py index b8660fbe61d..35926215e2e 100644 --- a/tests/electronic_structure/test_boltztrap2.py +++ b/tests/electronic_structure/test_boltztrap2.py @@ -5,10 +5,11 @@ import numpy as np import pytest from monty.serialization import loadfn +from pytest import approx + from pymatgen.electronic_structure.core import OrbitalType, Spin from pymatgen.io.vasp import Vasprun from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx try: from pymatgen.electronic_structure.boltztrap2 import ( diff --git a/tests/electronic_structure/test_cohp.py b/tests/electronic_structure/test_cohp.py index 2b44b6eca1b..2f9f827ba8b 100644 --- a/tests/electronic_structure/test_cohp.py +++ b/tests/electronic_structure/test_cohp.py @@ -5,6 +5,8 @@ import pytest from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.electronic_structure.cohp import ( Cohp, CompleteCohp, @@ -14,7 +16,6 @@ ) from pymatgen.electronic_structure.core import Orbital, Spin from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/cohp" diff --git a/tests/electronic_structure/test_core.py b/tests/electronic_structure/test_core.py index 243d1bef73b..2abad986cc4 100644 --- a/tests/electronic_structure/test_core.py +++ b/tests/electronic_structure/test_core.py @@ -3,6 +3,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose + from pymatgen.core import Lattice from pymatgen.electronic_structure.core import Magmom, Orbital, Spin diff --git a/tests/electronic_structure/test_dos.py b/tests/electronic_structure/test_dos.py index e515f0411c4..c69cbcc54ba 100644 --- a/tests/electronic_structure/test_dos.py +++ b/tests/electronic_structure/test_dos.py @@ -8,11 +8,12 @@ from monty.io import zopen from monty.serialization import loadfn from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core import Element, Structure from pymatgen.electronic_structure.core import Orbital, OrbitalType, Spin from pymatgen.electronic_structure.dos import DOS, CompleteDos, FermiDos, LobsterCompleteDos from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/dos" diff --git a/tests/electronic_structure/test_plotter.py b/tests/electronic_structure/test_plotter.py index 304c7216083..9728bc8d5d4 100644 --- a/tests/electronic_structure/test_plotter.py +++ b/tests/electronic_structure/test_plotter.py @@ -10,6 +10,8 @@ import pytest from matplotlib import rc from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core.structure import Structure from pymatgen.electronic_structure.bandstructure import BandStructureSymmLine from pymatgen.electronic_structure.boltztrap import BoltztrapAnalyzer @@ -29,7 +31,6 @@ ) from pymatgen.io.vasp import Vasprun from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest -from pytest import approx BAND_TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/bandstructure" diff --git a/tests/entries/test_compatibility.py b/tests/entries/test_compatibility.py index 7eeea95e918..850a4234d69 100644 --- a/tests/entries/test_compatibility.py +++ b/tests/entries/test_compatibility.py @@ -9,9 +9,11 @@ from typing import TYPE_CHECKING from unittest import TestCase -import pymatgen import pytest from monty.json import MontyDecoder +from pytest import approx + +import pymatgen from pymatgen.core import Element, Species from pymatgen.core.composition import Composition from pymatgen.core.lattice import Lattice @@ -32,7 +34,6 @@ ) from pymatgen.entries.computed_entries import ComputedEntry, ComputedStructureEntry, ConstantEnergyAdjustment from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx if TYPE_CHECKING: from pymatgen.util.typing import CompositionLike diff --git a/tests/entries/test_computed_entries.py b/tests/entries/test_computed_entries.py index a7a00c7f88c..aee3aade715 100644 --- a/tests/entries/test_computed_entries.py +++ b/tests/entries/test_computed_entries.py @@ -7,6 +7,8 @@ import pytest from monty.json import MontyDecoder +from pytest import approx + from pymatgen.analysis.phase_diagram import PhaseDiagram from pymatgen.entries.compatibility import MaterialsProject2020Compatibility from pymatgen.entries.computed_entries import ( @@ -21,7 +23,6 @@ ) from pymatgen.io.vasp.outputs import Vasprun from pymatgen.util.testing import TEST_FILES_DIR, VASP_OUT_DIR -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/entries" diff --git a/tests/entries/test_correction_calculator.py b/tests/entries/test_correction_calculator.py index c5b8f90a657..02d0fb517a8 100644 --- a/tests/entries/test_correction_calculator.py +++ b/tests/entries/test_correction_calculator.py @@ -3,6 +3,7 @@ from unittest import TestCase import pytest + from pymatgen.entries.correction_calculator import CorrectionCalculator from pymatgen.util.testing import TEST_FILES_DIR diff --git a/tests/entries/test_entry_tools.py b/tests/entries/test_entry_tools.py index a939dd4106e..01f4255d8ff 100644 --- a/tests/entries/test_entry_tools.py +++ b/tests/entries/test_entry_tools.py @@ -4,6 +4,7 @@ import pytest from monty.serialization import dumpfn, loadfn + from pymatgen.core import Element from pymatgen.entries.computed_entries import ComputedEntry from pymatgen.entries.entry_tools import EntrySet, group_entries_by_composition, group_entries_by_structure diff --git a/tests/entries/test_exp_entries.py b/tests/entries/test_exp_entries.py index 4ebb14d9d70..b73be4ad8a4 100644 --- a/tests/entries/test_exp_entries.py +++ b/tests/entries/test_exp_entries.py @@ -4,9 +4,10 @@ from unittest import TestCase from monty.json import MontyDecoder +from pytest import approx + from pymatgen.entries.exp_entries import ExpEntry from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx class TestExpEntry(TestCase): diff --git a/tests/entries/test_mixing_scheme.py b/tests/entries/test_mixing_scheme.py index 33d71c5a5b8..860ab42a0e7 100644 --- a/tests/entries/test_mixing_scheme.py +++ b/tests/entries/test_mixing_scheme.py @@ -108,6 +108,7 @@ import pytest from monty.json import MontyDecoder from numpy.testing import assert_allclose + from pymatgen.analysis.phase_diagram import PhaseDiagram from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core.lattice import Lattice diff --git a/tests/ext/test_cod.py b/tests/ext/test_cod.py index e2bc6ba9143..9a3164d03d0 100644 --- a/tests/ext/test_cod.py +++ b/tests/ext/test_cod.py @@ -6,6 +6,7 @@ import pytest import requests + from pymatgen.ext.cod import COD if "CI" in os.environ: # test is slow and flaky, skip in CI. see diff --git a/tests/ext/test_matproj.py b/tests/ext/test_matproj.py index 8489cf438c3..ec5ee928620 100644 --- a/tests/ext/test_matproj.py +++ b/tests/ext/test_matproj.py @@ -7,6 +7,9 @@ import pytest import requests from numpy.testing import assert_allclose +from pytest import approx +from ruamel.yaml import YAML + from pymatgen.analysis.phase_diagram import PhaseDiagram from pymatgen.analysis.pourbaix_diagram import PourbaixDiagram, PourbaixEntry from pymatgen.analysis.reaction_calculator import Reaction @@ -21,8 +24,6 @@ from pymatgen.phonon.bandstructure import PhononBandStructureSymmLine from pymatgen.phonon.dos import CompletePhononDos from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx -from ruamel.yaml import YAML try: skip_mprester_tests = requests.get("https://materialsproject.org", timeout=600).status_code != 200 diff --git a/tests/ext/test_optimade.py b/tests/ext/test_optimade.py index 2af457c38af..ea351acb8c7 100644 --- a/tests/ext/test_optimade.py +++ b/tests/ext/test_optimade.py @@ -2,6 +2,7 @@ import pytest import requests + from pymatgen.ext.optimade import OptimadeRester from pymatgen.util.testing import PymatgenTest diff --git a/tests/io/abinit/test_abiobjects.py b/tests/io/abinit/test_abiobjects.py index 5dcbff0b26d..8bbfa3a7441 100644 --- a/tests/io/abinit/test_abiobjects.py +++ b/tests/io/abinit/test_abiobjects.py @@ -3,6 +3,8 @@ import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.core.structure import Structure from pymatgen.core.units import Ha_to_eV, bohr_to_ang from pymatgen.io.abinit.abiobjects import ( @@ -18,7 +20,6 @@ structure_to_abivars, ) from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx class TestLatticeFromAbivars(PymatgenTest): diff --git a/tests/io/abinit/test_inputs.py b/tests/io/abinit/test_inputs.py index 287bfa68401..6becf8953f8 100644 --- a/tests/io/abinit/test_inputs.py +++ b/tests/io/abinit/test_inputs.py @@ -6,6 +6,7 @@ import numpy as np import pytest from numpy.testing import assert_array_equal + from pymatgen.core.structure import Structure from pymatgen.io.abinit.inputs import ( BasicAbinitInput, diff --git a/tests/io/abinit/test_netcdf.py b/tests/io/abinit/test_netcdf.py index 45f3343315c..cd01b0e4b90 100644 --- a/tests/io/abinit/test_netcdf.py +++ b/tests/io/abinit/test_netcdf.py @@ -3,6 +3,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal + from pymatgen.core.structure import Structure from pymatgen.io.abinit import EtsfReader from pymatgen.io.abinit.netcdf import AbinitHeader diff --git a/tests/io/abinit/test_pseudos.py b/tests/io/abinit/test_pseudos.py index 28a48cfcf1e..66b9e22f10e 100644 --- a/tests/io/abinit/test_pseudos.py +++ b/tests/io/abinit/test_pseudos.py @@ -4,9 +4,10 @@ from collections import defaultdict import pytest +from pytest import approx + from pymatgen.io.abinit.pseudos import Pseudo, PseudoTable from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/io/abinit" diff --git a/tests/io/aims/conftest.py b/tests/io/aims/conftest.py index 177aeb38001..5060ba4b259 100644 --- a/tests/io/aims/conftest.py +++ b/tests/io/aims/conftest.py @@ -3,6 +3,7 @@ import os import pytest + from pymatgen.core import SETTINGS module_dir = os.path.dirname(__file__) diff --git a/tests/io/aims/test_aims_inputs.py b/tests/io/aims/test_aims_inputs.py index 5ded1722eaf..d39baafd277 100644 --- a/tests/io/aims/test_aims_inputs.py +++ b/tests/io/aims/test_aims_inputs.py @@ -8,6 +8,7 @@ import pytest from monty.json import MontyDecoder, MontyEncoder from numpy.testing import assert_allclose + from pymatgen.core import SETTINGS from pymatgen.io.aims.inputs import ( ALLOWED_AIMS_CUBE_TYPES, diff --git a/tests/io/aims/test_aims_outputs.py b/tests/io/aims/test_aims_outputs.py index 1d675dad2a3..deb0554f658 100644 --- a/tests/io/aims/test_aims_outputs.py +++ b/tests/io/aims/test_aims_outputs.py @@ -6,6 +6,7 @@ from monty.json import MontyDecoder, MontyEncoder from numpy.testing import assert_allclose + from pymatgen.core import Structure from pymatgen.io.aims.outputs import AimsOutput diff --git a/tests/io/aims/test_aims_parsers.py b/tests/io/aims/test_aims_parsers.py index e6cb7d6eb7a..1d30799122d 100644 --- a/tests/io/aims/test_aims_parsers.py +++ b/tests/io/aims/test_aims_parsers.py @@ -6,6 +6,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose + from pymatgen.core.tensors import Tensor from pymatgen.io.aims.parsers import ( EV_PER_A3_TO_KBAR, diff --git a/tests/io/aims/test_sets/test_input_set.py b/tests/io/aims/test_sets/test_input_set.py index f5d87fe3881..fb7acf5011d 100644 --- a/tests/io/aims/test_sets/test_input_set.py +++ b/tests/io/aims/test_sets/test_input_set.py @@ -5,6 +5,7 @@ from pathlib import Path import pytest + from pymatgen.core import Structure from pymatgen.io.aims.sets import AimsInputSet diff --git a/tests/io/aims/test_sets/test_md_generator.py b/tests/io/aims/test_sets/test_md_generator.py index 13c6f8f6859..f8b9f71cbef 100644 --- a/tests/io/aims/test_sets/test_md_generator.py +++ b/tests/io/aims/test_sets/test_md_generator.py @@ -5,6 +5,7 @@ from pathlib import Path import pytest + from pymatgen.io.aims.sets.core import MDSetGenerator from pymatgen.util.testing.aims import Si, compare_files diff --git a/tests/io/cp2k/test_inputs.py b/tests/io/cp2k/test_inputs.py index 9120a789f6d..a4b344cda19 100644 --- a/tests/io/cp2k/test_inputs.py +++ b/tests/io/cp2k/test_inputs.py @@ -3,6 +3,8 @@ import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.core.structure import Molecule, Structure from pymatgen.io.cp2k.inputs import ( BasisFile, @@ -21,7 +23,6 @@ SectionList, ) from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/io/cp2k" diff --git a/tests/io/cp2k/test_outputs.py b/tests/io/cp2k/test_outputs.py index fafe2b8be91..cd3214af175 100644 --- a/tests/io/cp2k/test_outputs.py +++ b/tests/io/cp2k/test_outputs.py @@ -4,9 +4,10 @@ import numpy as np from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.io.cp2k.outputs import Cp2kOutput from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/io/cp2k" diff --git a/tests/io/cp2k/test_sets.py b/tests/io/cp2k/test_sets.py index c986f02db6a..ecb644a82a3 100644 --- a/tests/io/cp2k/test_sets.py +++ b/tests/io/cp2k/test_sets.py @@ -1,10 +1,11 @@ from __future__ import annotations import pytest +from pytest import approx + from pymatgen.core.structure import Molecule, Structure from pymatgen.io.cp2k.sets import SETTINGS, Cp2kValidationError, DftSet, GaussianTypeOrbitalBasisSet, GthPotential from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/io/cp2k" diff --git a/tests/io/exciting/test_inputs.py b/tests/io/exciting/test_inputs.py index 02528023893..a5a221221b3 100644 --- a/tests/io/exciting/test_inputs.py +++ b/tests/io/exciting/test_inputs.py @@ -3,6 +3,7 @@ from xml.etree import ElementTree from numpy.testing import assert_allclose + from pymatgen.core import Lattice, Structure from pymatgen.io.exciting import ExcitingInput from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest diff --git a/tests/io/feff/test_inputs.py b/tests/io/feff/test_inputs.py index cf06dd92bf9..b95bcc536e1 100644 --- a/tests/io/feff/test_inputs.py +++ b/tests/io/feff/test_inputs.py @@ -4,10 +4,11 @@ from unittest import TestCase from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core import Molecule, Structure from pymatgen.io.feff.inputs import Atoms, Header, Paths, Potential, Tags from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx FEFF_TEST_DIR = f"{TEST_FILES_DIR}/io/feff" diff --git a/tests/io/feff/test_sets.py b/tests/io/feff/test_sets.py index 059d2422550..e57e560996c 100644 --- a/tests/io/feff/test_sets.py +++ b/tests/io/feff/test_sets.py @@ -5,6 +5,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose + from pymatgen.core.structure import Lattice, Molecule, Structure from pymatgen.io.feff.inputs import Atoms, Header, Potential, Tags from pymatgen.io.feff.sets import FEFFDictSet, MPELNESSet, MPEXAFSSet, MPXANESSet diff --git a/tests/io/lammps/test_data.py b/tests/io/lammps/test_data.py index e88732fb033..d2fb6541926 100644 --- a/tests/io/lammps/test_data.py +++ b/tests/io/lammps/test_data.py @@ -10,11 +10,12 @@ import pytest from monty.json import MontyDecoder, MontyEncoder from numpy.testing import assert_allclose +from pytest import approx +from ruamel.yaml import YAML + from pymatgen.core import Element, Lattice, Molecule, Structure from pymatgen.io.lammps.data import CombinedData, ForceField, LammpsBox, LammpsData, Topology, lattice_2_lmpbox from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx -from ruamel.yaml import YAML TEST_DIR = f"{TEST_FILES_DIR}/io/lammps" diff --git a/tests/io/lammps/test_inputs.py b/tests/io/lammps/test_inputs.py index a3abdcceb16..d56765fdad3 100644 --- a/tests/io/lammps/test_inputs.py +++ b/tests/io/lammps/test_inputs.py @@ -6,6 +6,7 @@ import pandas as pd import pytest + from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.io.lammps.data import LammpsData diff --git a/tests/io/lammps/test_outputs.py b/tests/io/lammps/test_outputs.py index e982cf21f18..6d5e83c3089 100644 --- a/tests/io/lammps/test_outputs.py +++ b/tests/io/lammps/test_outputs.py @@ -7,6 +7,7 @@ import numpy as np import pandas as pd from numpy.testing import assert_allclose + from pymatgen.io.lammps.outputs import LammpsDump, parse_lammps_dumps, parse_lammps_log from pymatgen.util.testing import TEST_FILES_DIR diff --git a/tests/io/lobster/test_inputs.py b/tests/io/lobster/test_inputs.py index 62f413a1947..646a2f70eb3 100644 --- a/tests/io/lobster/test_inputs.py +++ b/tests/io/lobster/test_inputs.py @@ -7,6 +7,8 @@ import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.core.structure import Structure from pymatgen.electronic_structure.cohp import IcohpCollection from pymatgen.electronic_structure.core import Orbital, Spin @@ -30,7 +32,6 @@ from pymatgen.io.vasp import Vasprun from pymatgen.io.vasp.inputs import Incar, Kpoints, Potcar from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/cohp" diff --git a/tests/io/lobster/test_lobsterenv.py b/tests/io/lobster/test_lobsterenv.py index 9a4230e232e..6ee94d82902 100644 --- a/tests/io/lobster/test_lobsterenv.py +++ b/tests/io/lobster/test_lobsterenv.py @@ -5,6 +5,8 @@ import numpy as np import pytest +from pytest import approx + from pymatgen.analysis.graphs import StructureGraph from pymatgen.core import Element from pymatgen.core.structure import Structure @@ -13,7 +15,6 @@ from pymatgen.io.lobster import Charge, Icohplist from pymatgen.io.lobster.lobsterenv import LobsterNeighbors from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx __author__ = "Janine George" __copyright__ = "Copyright 2021, The Materials Project" diff --git a/tests/io/pwmat/test_inputs.py b/tests/io/pwmat/test_inputs.py index 8ee41de8552..1343ef6832a 100644 --- a/tests/io/pwmat/test_inputs.py +++ b/tests/io/pwmat/test_inputs.py @@ -3,6 +3,7 @@ import pytest from monty.io import zopen from numpy.testing import assert_allclose + from pymatgen.core import Composition, Structure from pymatgen.io.pwmat.inputs import ( ACExtractor, diff --git a/tests/io/qchem/test_inputs.py b/tests/io/qchem/test_inputs.py index c5c0515fa57..6a49daba428 100644 --- a/tests/io/qchem/test_inputs.py +++ b/tests/io/qchem/test_inputs.py @@ -5,6 +5,7 @@ import pytest from monty.serialization import loadfn + from pymatgen.core.structure import Molecule from pymatgen.io.qchem.inputs import QCInput from pymatgen.io.qchem.sets import OptSet diff --git a/tests/io/qchem/test_outputs.py b/tests/io/qchem/test_outputs.py index 31e54f67b3f..bd900253583 100644 --- a/tests/io/qchem/test_outputs.py +++ b/tests/io/qchem/test_outputs.py @@ -7,6 +7,8 @@ import pytest from monty.serialization import dumpfn, loadfn from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core.structure import Molecule from pymatgen.io.qchem.outputs import ( QCOutput, @@ -16,7 +18,6 @@ orbital_coeffs_parser, ) from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx try: from openbabel import openbabel diff --git a/tests/io/qchem/test_sets.py b/tests/io/qchem/test_sets.py index aa2037dac17..041003d4428 100644 --- a/tests/io/qchem/test_sets.py +++ b/tests/io/qchem/test_sets.py @@ -3,6 +3,7 @@ import os import pytest + from pymatgen.io.qchem.sets import ( ForceSet, FreqSet, diff --git a/tests/io/qchem/test_utils.py b/tests/io/qchem/test_utils.py index 260dd803462..394ab8c142b 100644 --- a/tests/io/qchem/test_utils.py +++ b/tests/io/qchem/test_utils.py @@ -5,6 +5,7 @@ import pytest from monty.io import zopen + from pymatgen.io.qchem.utils import lower_and_check_unique, process_parsed_hess from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest diff --git a/tests/io/test_adf.py b/tests/io/test_adf.py index 702fbc87d72..d3b6785320f 100644 --- a/tests/io/test_adf.py +++ b/tests/io/test_adf.py @@ -1,9 +1,10 @@ from __future__ import annotations +from pytest import approx + from pymatgen.core.structure import Molecule from pymatgen.io.adf import AdfInput, AdfKey, AdfOutput, AdfTask from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx __author__ = "Xin Chen, chenxin13@mails.tsinghua.edu.cn" diff --git a/tests/io/test_ase.py b/tests/io/test_ase.py index 5ed59b6afff..daf7b0c77bd 100644 --- a/tests/io/test_ase.py +++ b/tests/io/test_ase.py @@ -3,6 +3,7 @@ import numpy as np import pytest from monty.json import MontyDecoder, jsanitize + from pymatgen.core import Composition, Lattice, Molecule, Structure from pymatgen.core.structure import StructureError from pymatgen.io.ase import AseAtomsAdaptor, MSONAtoms diff --git a/tests/io/test_atat.py b/tests/io/test_atat.py index 6cf13574495..a9562f92511 100644 --- a/tests/io/test_atat.py +++ b/tests/io/test_atat.py @@ -1,10 +1,11 @@ from __future__ import annotations from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core.structure import Structure from pymatgen.io.atat import Mcsqs from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/io/atat/mcsqs" diff --git a/tests/io/test_babel.py b/tests/io/test_babel.py index 589330d94c5..e1724176ec4 100644 --- a/tests/io/test_babel.py +++ b/tests/io/test_babel.py @@ -4,13 +4,14 @@ from unittest import TestCase import pytest +from pytest import approx + from pymatgen.analysis.graphs import MoleculeGraph from pymatgen.analysis.molecule_matcher import MoleculeMatcher from pymatgen.core.structure import Molecule from pymatgen.io.babel import BabelMolAdaptor from pymatgen.io.xyz import XYZ from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx pybel = pytest.importorskip("openbabel.pybel") diff --git a/tests/io/test_cif.py b/tests/io/test_cif.py index 8abc5127813..f536a4f4021 100644 --- a/tests/io/test_cif.py +++ b/tests/io/test_cif.py @@ -2,13 +2,14 @@ import numpy as np import pytest +from pytest import approx + from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core import Composition, DummySpecies, Element, Lattice, Species, Structure from pymatgen.electronic_structure.core import Magmom from pymatgen.io.cif import CifBlock, CifParser, CifWriter from pymatgen.symmetry.structure import SymmetrizedStructure from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest -from pytest import approx try: import pybtex diff --git a/tests/io/test_core.py b/tests/io/test_core.py index 7c457339249..f3f08b46185 100644 --- a/tests/io/test_core.py +++ b/tests/io/test_core.py @@ -6,6 +6,7 @@ import pytest from monty.serialization import MontyDecoder + from pymatgen.core.structure import Structure from pymatgen.io.cif import CifParser, CifWriter from pymatgen.io.core import InputFile, InputSet diff --git a/tests/io/test_gaussian.py b/tests/io/test_gaussian.py index fc694fa7f97..7dc76b78b1b 100644 --- a/tests/io/test_gaussian.py +++ b/tests/io/test_gaussian.py @@ -3,11 +3,12 @@ from unittest import TestCase import pytest +from pytest import approx + from pymatgen.core.structure import Molecule from pymatgen.electronic_structure.core import Spin from pymatgen.io.gaussian import GaussianInput, GaussianOutput from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/io/gaussian" diff --git a/tests/io/test_jarvis.py b/tests/io/test_jarvis.py index 00a6b4f88f0..75c3c78eb82 100644 --- a/tests/io/test_jarvis.py +++ b/tests/io/test_jarvis.py @@ -1,6 +1,7 @@ from __future__ import annotations import pytest + from pymatgen.core import Structure from pymatgen.io.jarvis import Atoms, JarvisAtomsAdaptor from pymatgen.util.testing import VASP_IN_DIR diff --git a/tests/io/test_lmto.py b/tests/io/test_lmto.py index d398bd431b3..393a0b06bae 100644 --- a/tests/io/test_lmto.py +++ b/tests/io/test_lmto.py @@ -4,6 +4,7 @@ import numpy as np from numpy.testing import assert_array_equal + from pymatgen.core.structure import Structure from pymatgen.core.units import Ry_to_eV from pymatgen.electronic_structure.core import Spin diff --git a/tests/io/test_nwchem.py b/tests/io/test_nwchem.py index 5f4a13c8b5a..a81dc751ec0 100644 --- a/tests/io/test_nwchem.py +++ b/tests/io/test_nwchem.py @@ -4,10 +4,11 @@ from unittest import TestCase import pytest +from pytest import approx + from pymatgen.core.structure import Molecule from pymatgen.io.nwchem import NwInput, NwInputError, NwOutput, NwTask from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/io/nwchem" diff --git a/tests/io/test_openff.py b/tests/io/test_openff.py index 41057daeb0b..2152b3e955e 100644 --- a/tests/io/test_openff.py +++ b/tests/io/test_openff.py @@ -5,6 +5,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose + from pymatgen.analysis.graphs import MoleculeGraph from pymatgen.analysis.local_env import OpenBabelNN from pymatgen.core import Molecule diff --git a/tests/io/test_packmol.py b/tests/io/test_packmol.py index e82f627e310..15d3c86b547 100644 --- a/tests/io/test_packmol.py +++ b/tests/io/test_packmol.py @@ -6,6 +6,7 @@ from subprocess import TimeoutExpired import pytest + from pymatgen.analysis.molecule_matcher import MoleculeMatcher from pymatgen.core import Molecule from pymatgen.io.packmol import PackmolBoxGen diff --git a/tests/io/test_phonopy.py b/tests/io/test_phonopy.py index c3bc2e18187..f12cce1f0a0 100644 --- a/tests/io/test_phonopy.py +++ b/tests/io/test_phonopy.py @@ -7,6 +7,8 @@ import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.core import Element from pymatgen.io.phonopy import ( CompletePhononDos, @@ -27,7 +29,6 @@ get_thermal_displacement_matrices, ) from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx try: from phonopy import Phonopy diff --git a/tests/io/test_pwscf.py b/tests/io/test_pwscf.py index 124e4784a42..ea6dd7c3af0 100644 --- a/tests/io/test_pwscf.py +++ b/tests/io/test_pwscf.py @@ -3,9 +3,10 @@ import numpy as np import pytest from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.io.pwscf import PWInput, PWInputError, PWOutput from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/io/pwscf" diff --git a/tests/io/test_res.py b/tests/io/test_res.py index 2e05ee5769a..5617ad86492 100644 --- a/tests/io/test_res.py +++ b/tests/io/test_res.py @@ -1,10 +1,11 @@ from __future__ import annotations import pytest +from pytest import approx + from pymatgen.core import Structure from pymatgen.io.res import AirssProvider, ResParseError, ResWriter from pymatgen.util.testing import TEST_FILES_DIR -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/io/res" diff --git a/tests/io/test_shengbte.py b/tests/io/test_shengbte.py index 60bc58b2a4a..67779c458a1 100644 --- a/tests/io/test_shengbte.py +++ b/tests/io/test_shengbte.py @@ -4,6 +4,7 @@ import pytest from numpy.testing import assert_array_equal + from pymatgen.io.shengbte import Control from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest diff --git a/tests/io/test_template_input.py b/tests/io/test_template_input.py index 313fa8fc540..3be8ae45374 100644 --- a/tests/io/test_template_input.py +++ b/tests/io/test_template_input.py @@ -3,6 +3,7 @@ import os import pytest + from pymatgen.io.template import TemplateInputGen from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest diff --git a/tests/io/test_wannier90.py b/tests/io/test_wannier90.py index 32757970eeb..ca4704dfe72 100644 --- a/tests/io/test_wannier90.py +++ b/tests/io/test_wannier90.py @@ -5,9 +5,10 @@ import numpy as np import pytest from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.io.wannier90 import Unk from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/io/wannier90" diff --git a/tests/io/test_xcrysden.py b/tests/io/test_xcrysden.py index 88db940bcf8..3a13a2cf7b5 100644 --- a/tests/io/test_xcrysden.py +++ b/tests/io/test_xcrysden.py @@ -1,6 +1,7 @@ from __future__ import annotations import numpy as np + from pymatgen.core.structure import Structure from pymatgen.io.xcrysden import XSF from pymatgen.util.testing import PymatgenTest diff --git a/tests/io/test_xyz.py b/tests/io/test_xyz.py index 77e3c582efa..2314eefdc8e 100644 --- a/tests/io/test_xyz.py +++ b/tests/io/test_xyz.py @@ -4,11 +4,12 @@ import pandas as pd import pytest +from pytest import approx + from pymatgen.core import Structure from pymatgen.core.structure import Molecule from pymatgen.io.xyz import XYZ from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR -from pytest import approx class TestXYZ(TestCase): diff --git a/tests/io/test_zeopp.py b/tests/io/test_zeopp.py index 3656530cb4e..2f38d24086c 100644 --- a/tests/io/test_zeopp.py +++ b/tests/io/test_zeopp.py @@ -4,6 +4,8 @@ from unittest import TestCase import pytest +from pytest import approx + from pymatgen.analysis.bond_valence import BVAnalyzer from pymatgen.core import Molecule, Species, Structure from pymatgen.io.zeopp import ( @@ -14,7 +16,6 @@ get_voronoi_nodes, ) from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR -from pytest import approx try: import zeo diff --git a/tests/io/vasp/test_inputs.py b/tests/io/vasp/test_inputs.py index aba859bea1f..cfd2769ff5e 100644 --- a/tests/io/vasp/test_inputs.py +++ b/tests/io/vasp/test_inputs.py @@ -15,6 +15,8 @@ from monty.io import zopen from monty.serialization import loadfn from numpy.testing import assert_allclose +from pytest import MonkeyPatch, approx + from pymatgen.core import SETTINGS from pymatgen.core.composition import Composition from pymatgen.core.structure import Structure @@ -34,7 +36,6 @@ _gen_potcar_summary_stats, ) from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest -from pytest import MonkeyPatch, approx # make sure _gen_potcar_summary_stats runs and works with all tests in this file _summ_stats = _gen_potcar_summary_stats(append=False, vasp_psp_dir=str(FAKE_POTCAR_DIR), summary_stats_filename=None) diff --git a/tests/io/vasp/test_optics.py b/tests/io/vasp/test_optics.py index 3e660a58797..3a2caf7a94a 100644 --- a/tests/io/vasp/test_optics.py +++ b/tests/io/vasp/test_optics.py @@ -4,6 +4,7 @@ import pytest import scipy.special from numpy.testing import assert_allclose + from pymatgen.io.vasp.optics import DielectricFunctionCalculator, delta_func, delta_methfessel_paxton, step_func from pymatgen.io.vasp.outputs import Vasprun from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest diff --git a/tests/io/vasp/test_outputs.py b/tests/io/vasp/test_outputs.py index fb2a9697842..a5faadac3ca 100644 --- a/tests/io/vasp/test_outputs.py +++ b/tests/io/vasp/test_outputs.py @@ -13,6 +13,8 @@ import pytest from monty.io import zopen from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core import Element from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure @@ -40,7 +42,6 @@ ) from pymatgen.io.wannier90 import Unk from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest -from pytest import approx try: import h5py diff --git a/tests/io/vasp/test_sets.py b/tests/io/vasp/test_sets.py index 354acd70b46..90828a5a58d 100644 --- a/tests/io/vasp/test_sets.py +++ b/tests/io/vasp/test_sets.py @@ -10,6 +10,8 @@ from monty.json import MontyDecoder from monty.serialization import loadfn from numpy.testing import assert_allclose +from pytest import MonkeyPatch, approx, mark + from pymatgen.analysis.structure_matcher import StructureMatcher from pymatgen.core import SETTINGS, Lattice, Species, Structure from pymatgen.core.composition import Composition @@ -53,7 +55,6 @@ ) from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.util.testing import FAKE_POTCAR_DIR, TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest -from pytest import MonkeyPatch, approx, mark TEST_DIR = f"{TEST_FILES_DIR}/io/vasp" diff --git a/tests/io/xtb/test_outputs.py b/tests/io/xtb/test_outputs.py index dd1afc090af..c4d3fe69777 100644 --- a/tests/io/xtb/test_outputs.py +++ b/tests/io/xtb/test_outputs.py @@ -2,11 +2,12 @@ import os +from pytest import approx + from pymatgen.core.structure import Molecule from pymatgen.io.qchem.outputs import check_for_structure_changes from pymatgen.io.xtb.outputs import CRESTOutput from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx try: from openbabel import openbabel diff --git a/tests/optimization/test_linear_assignment.py b/tests/optimization/test_linear_assignment.py index 163a1ac3132..961a5032b6d 100644 --- a/tests/optimization/test_linear_assignment.py +++ b/tests/optimization/test_linear_assignment.py @@ -4,9 +4,10 @@ import numpy as np import pytest -from pymatgen.optimization.linear_assignment import LinearAssignment from pytest import approx +from pymatgen.optimization.linear_assignment import LinearAssignment + class TestLinearAssignment(TestCase): def test(self): diff --git a/tests/optimization/test_neighbors.py b/tests/optimization/test_neighbors.py index 8d66dcd9b91..a6374c1f929 100644 --- a/tests/optimization/test_neighbors.py +++ b/tests/optimization/test_neighbors.py @@ -1,6 +1,7 @@ from __future__ import annotations import numpy as np + from pymatgen.core.lattice import Lattice from pymatgen.optimization.neighbors import find_points_in_spheres from pymatgen.util.testing import PymatgenTest diff --git a/tests/phonon/test_bandstructure.py b/tests/phonon/test_bandstructure.py index 6f46c3dca38..7f449792544 100644 --- a/tests/phonon/test_bandstructure.py +++ b/tests/phonon/test_bandstructure.py @@ -4,10 +4,11 @@ import json from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.electronic_structure.bandstructure import Kpoint from pymatgen.phonon.bandstructure import PhononBandStructureSymmLine from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/bandstructure" diff --git a/tests/phonon/test_dos.py b/tests/phonon/test_dos.py index 013cfa7e8b3..0fecb44d6fd 100644 --- a/tests/phonon/test_dos.py +++ b/tests/phonon/test_dos.py @@ -5,10 +5,11 @@ import numpy as np import pytest +from pytest import approx + from pymatgen.core import Element from pymatgen.phonon.dos import CompletePhononDos, PhononDos from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/phonon/dos" diff --git a/tests/phonon/test_gruneisen.py b/tests/phonon/test_gruneisen.py index 3040db72cf3..36f1d66fa22 100644 --- a/tests/phonon/test_gruneisen.py +++ b/tests/phonon/test_gruneisen.py @@ -4,11 +4,12 @@ import numpy as np import pytest from matplotlib import colors +from pytest import approx + from pymatgen.io.phonopy import get_gruneisen_ph_bs_symm_line, get_gruneisenparameter from pymatgen.phonon.gruneisen import GruneisenParameter from pymatgen.phonon.plotter import GruneisenPhononBandStructureSymmLine, GruneisenPhononBSPlotter, GruneisenPlotter from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx try: import phonopy diff --git a/tests/phonon/test_ir_spectra.py b/tests/phonon/test_ir_spectra.py index 11bae39d9f7..7a7eb40f4ce 100644 --- a/tests/phonon/test_ir_spectra.py +++ b/tests/phonon/test_ir_spectra.py @@ -1,6 +1,7 @@ from __future__ import annotations from monty.serialization import loadfn + from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest diff --git a/tests/phonon/test_plotter.py b/tests/phonon/test_plotter.py index 2e0c762804b..01e657e7eaf 100644 --- a/tests/phonon/test_plotter.py +++ b/tests/phonon/test_plotter.py @@ -6,6 +6,7 @@ import matplotlib.pyplot as plt import pytest from numpy.testing import assert_allclose + from pymatgen.phonon import CompletePhononDos, PhononBandStructureSymmLine from pymatgen.phonon.plotter import PhononBSPlotter, PhononDosPlotter, ThermoPlotter from pymatgen.util.testing import TEST_FILES_DIR diff --git a/tests/phonon/test_thermal_displacements.py b/tests/phonon/test_thermal_displacements.py index 315680e28d8..725c197263f 100644 --- a/tests/phonon/test_thermal_displacements.py +++ b/tests/phonon/test_thermal_displacements.py @@ -2,10 +2,11 @@ import numpy as np from numpy.testing import assert_allclose +from pytest import approx + from pymatgen.core.structure import Structure from pymatgen.phonon.thermal_displacements import ThermalDisplacementMatrices from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/phonon/thermal_displacement_matrices" diff --git a/tests/symmetry/test_analyzer.py b/tests/symmetry/test_analyzer.py index 41c7b72e6c1..14de4656202 100644 --- a/tests/symmetry/test_analyzer.py +++ b/tests/symmetry/test_analyzer.py @@ -6,6 +6,9 @@ import numpy as np import pytest from numpy.testing import assert_allclose +from pytest import approx, raises +from spglib import SpglibDataset + from pymatgen.core import Lattice, Molecule, PeriodicSite, Site, Species, Structure from pymatgen.io.vasp.outputs import Vasprun from pymatgen.symmetry.analyzer import ( @@ -17,8 +20,6 @@ ) from pymatgen.symmetry.structure import SymmetrizedStructure from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, VASP_OUT_DIR, PymatgenTest -from pytest import approx, raises -from spglib import SpglibDataset TEST_DIR = f"{TEST_FILES_DIR}/symmetry/analyzer" diff --git a/tests/symmetry/test_groups.py b/tests/symmetry/test_groups.py index ae9b3a0a9f7..5a2b6fd66a4 100644 --- a/tests/symmetry/test_groups.py +++ b/tests/symmetry/test_groups.py @@ -2,10 +2,11 @@ import numpy as np import pytest +from pytest import approx + from pymatgen.core.lattice import Lattice from pymatgen.core.operations import SymmOp from pymatgen.symmetry.groups import SYMM_DATA, PointGroup, SpaceGroup -from pytest import approx __author__ = "Shyue Ping Ong" __copyright__ = "Copyright 2012, The Materials Virtual Lab" diff --git a/tests/symmetry/test_kpath_hin.py b/tests/symmetry/test_kpath_hin.py index 63dab783ac2..61d71fd9dd3 100644 --- a/tests/symmetry/test_kpath_hin.py +++ b/tests/symmetry/test_kpath_hin.py @@ -1,11 +1,12 @@ from __future__ import annotations import pytest +from pytest import approx + from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.symmetry.kpath import KPathSeek from pymatgen.util.testing import PymatgenTest -from pytest import approx try: from seekpath import get_path diff --git a/tests/symmetry/test_kpath_lm.py b/tests/symmetry/test_kpath_lm.py index e72ff7ef9d7..dbc8187e6a9 100644 --- a/tests/symmetry/test_kpath_lm.py +++ b/tests/symmetry/test_kpath_lm.py @@ -1,13 +1,14 @@ from __future__ import annotations import numpy as np +from pytest import approx + from pymatgen.analysis.magnetism.analyzer import CollinearMagneticStructureAnalyzer from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.symmetry.kpath import KPathLatimerMunro from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx class TestKPathLatimerMunro(PymatgenTest): diff --git a/tests/symmetry/test_kpath_sc.py b/tests/symmetry/test_kpath_sc.py index 2dd37d0d77e..d88c97f79dd 100644 --- a/tests/symmetry/test_kpath_sc.py +++ b/tests/symmetry/test_kpath_sc.py @@ -1,11 +1,12 @@ from __future__ import annotations import numpy as np +from pytest import approx + from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.symmetry.kpath import KPathSetyawanCurtarolo from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest -from pytest import approx TEST_DIR = f"{TEST_FILES_DIR}/symmetry/space_group_structs" diff --git a/tests/symmetry/test_kpaths.py b/tests/symmetry/test_kpaths.py index f13ae4b7a9b..2c907e87135 100644 --- a/tests/symmetry/test_kpaths.py +++ b/tests/symmetry/test_kpaths.py @@ -4,6 +4,7 @@ import pytest from monty.serialization import loadfn + from pymatgen.core.lattice import Lattice from pymatgen.core.structure import Structure from pymatgen.symmetry.bandstructure import HighSymmKpath diff --git a/tests/symmetry/test_maggroups.py b/tests/symmetry/test_maggroups.py index cc4d529b87c..72f184d553f 100644 --- a/tests/symmetry/test_maggroups.py +++ b/tests/symmetry/test_maggroups.py @@ -2,6 +2,7 @@ import numpy as np from numpy.testing import assert_allclose + from pymatgen.core.lattice import Lattice from pymatgen.symmetry.groups import SpaceGroup from pymatgen.symmetry.maggroups import MagneticSpaceGroup diff --git a/tests/symmetry/test_settings.py b/tests/symmetry/test_settings.py index a6a8ff3e80a..24db5b2b6dc 100644 --- a/tests/symmetry/test_settings.py +++ b/tests/symmetry/test_settings.py @@ -4,6 +4,7 @@ import numpy as np from numpy.testing import assert_allclose + from pymatgen.symmetry.settings import JonesFaithfulTransformation, Lattice, SymmOp __author__ = "Matthew Horton" diff --git a/tests/symmetry/test_site_symmetries.py b/tests/symmetry/test_site_symmetries.py index c5696b31f46..21972990e8b 100644 --- a/tests/symmetry/test_site_symmetries.py +++ b/tests/symmetry/test_site_symmetries.py @@ -4,6 +4,7 @@ import json from monty.json import MontyDecoder + from pymatgen.symmetry import site_symmetries as ss from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest diff --git a/tests/test_cli.py b/tests/test_cli.py index 1893d0a5738..225664313dc 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -4,6 +4,7 @@ from typing import TYPE_CHECKING import pytest + from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR if TYPE_CHECKING: diff --git a/tests/transformations/test_advanced_transformations.py b/tests/transformations/test_advanced_transformations.py index ea0feed09b8..5dcc3fae6d4 100644 --- a/tests/transformations/test_advanced_transformations.py +++ b/tests/transformations/test_advanced_transformations.py @@ -7,6 +7,8 @@ import pytest from monty.serialization import loadfn from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.analysis.energy_models import IsingModel, SymmetryModel from pymatgen.analysis.gb.grain import GrainBoundaryGenerator from pymatgen.core import Lattice, Molecule, Species, Structure @@ -39,7 +41,6 @@ SubstitutionTransformation, ) from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest -from pytest import approx try: import hiphive diff --git a/tests/transformations/test_site_transformations.py b/tests/transformations/test_site_transformations.py index cddc9bfb53f..3b30670fad3 100644 --- a/tests/transformations/test_site_transformations.py +++ b/tests/transformations/test_site_transformations.py @@ -6,6 +6,7 @@ import numpy as np import pytest from numpy.testing import assert_allclose + from pymatgen.core.structure import Molecule, Structure from pymatgen.transformations.site_transformations import ( AddSitePropertyTransformation, diff --git a/tests/transformations/test_standard_transformations.py b/tests/transformations/test_standard_transformations.py index 029fad0f8e7..331ed94b9c9 100644 --- a/tests/transformations/test_standard_transformations.py +++ b/tests/transformations/test_standard_transformations.py @@ -9,6 +9,8 @@ import numpy as np import pytest from monty.json import MontyDecoder +from pytest import approx + from pymatgen.core import Element, PeriodicSite from pymatgen.core.lattice import Lattice from pymatgen.symmetry.structure import SymmetrizedStructure @@ -34,7 +36,6 @@ SupercellTransformation, ) from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR -from pytest import approx enumlib_present = which("enum.x") and which("makestr.x") diff --git a/tests/util/test_coord.py b/tests/util/test_coord.py index 433831f3c5d..15cfab9d7dc 100644 --- a/tests/util/test_coord.py +++ b/tests/util/test_coord.py @@ -6,9 +6,10 @@ import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal +from pytest import approx + from pymatgen.core.lattice import Lattice from pymatgen.util import coord -from pytest import approx class TestCoordUtils: diff --git a/tests/util/test_num.py b/tests/util/test_num.py index 8891e37ca0f..e391ba92412 100644 --- a/tests/util/test_num.py +++ b/tests/util/test_num.py @@ -1,6 +1,7 @@ from __future__ import annotations import pytest + from pymatgen.util.num import round_to_sigfigs diff --git a/tests/util/test_plotting.py b/tests/util/test_plotting.py index 85d91b457e8..ae0b6eca76b 100644 --- a/tests/util/test_plotting.py +++ b/tests/util/test_plotting.py @@ -1,6 +1,7 @@ from __future__ import annotations import matplotlib.pyplot as plt + from pymatgen.util.plotting import periodic_table_heatmap, van_arkel_triangle from pymatgen.util.testing import PymatgenTest diff --git a/tests/util/test_provenance.py b/tests/util/test_provenance.py index 9019ee50ebd..12ebbb2b13b 100644 --- a/tests/util/test_provenance.py +++ b/tests/util/test_provenance.py @@ -7,6 +7,7 @@ import numpy as np import pytest + from pymatgen.core.structure import Molecule, Structure from pymatgen.util.provenance import Author, HistoryNode, StructureNL diff --git a/tests/util/test_string.py b/tests/util/test_string.py index 1bb0785cef3..5c04a1d51ea 100644 --- a/tests/util/test_string.py +++ b/tests/util/test_string.py @@ -2,6 +2,7 @@ import numpy as np import pytest + from pymatgen.core import Structure from pymatgen.util.string import ( Stringify, diff --git a/tests/util/test_typing.py b/tests/util/test_typing.py index 9b56e8d4705..994e8731af6 100644 --- a/tests/util/test_typing.py +++ b/tests/util/test_typing.py @@ -10,6 +10,7 @@ from typing import TYPE_CHECKING, get_args import pytest + from pymatgen.core import Composition, DummySpecies, Element, Species from pymatgen.entries import Entry from pymatgen.util.typing import CompositionLike, EntryLike, PathLike, PbcLike, SpeciesLike diff --git a/tests/vis/test_plotters.py b/tests/vis/test_plotters.py index ab9c95ad547..ca0594b4c2d 100644 --- a/tests/vis/test_plotters.py +++ b/tests/vis/test_plotters.py @@ -6,6 +6,7 @@ import matplotlib.pyplot as plt import numpy as np from monty.json import MontyDecoder + from pymatgen.analysis.xas.spectrum import XAS from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest from pymatgen.vis.plotters import SpectrumPlotter