Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-commit autoupdate #404

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,46 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.8.6
hooks:
- id: ruff
args: [ --fix, --unsafe-fixes ]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.1
rev: v1.14.1
hooks:
- id: mypy

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
stages: [ commit, commit-msg ]
stages: [ pre-commit, commit-msg ]
exclude_types: [ html ]
additional_dependencies: [ tomli ] # needed to read pyproject.toml below py3.11

- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.16.2
rev: v0.16.6
hooks:
- id: cython-lint
args: [ --no-pycodestyle ]
- id: double-quote-cython-strings

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
rev: 1.19.1
hooks:
- id: blacken-docs

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
rev: v0.43.0
hooks:
- id: markdownlint
# MD013: line too long
Expand All @@ -58,12 +58,12 @@ repos:
args: [ --disable, MD013, MD024, MD025, MD033, MD041, "--" ]

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
rev: 0.8.1
hooks:
- id: nbstripout
args: [ --drop-empty-cells, --keep-output ]

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.369
rev: v1.1.391
hooks:
- id: pyright
3 changes: 1 addition & 2 deletions examples/neb_idpp_solver.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"init_struct = Structure.from_file(os.path.join(dirname, \"CONTCAR-0\"), False)\n",
"final_struct = Structure.from_file(os.path.join(dirname, \"CONTCAR-1\"), False)\n",
"\n",
"obj = IDPPSolver.from_endpoints(endpoints=[init_struct, final_struct], nimages=3,\n",
" sort_tol=1.0)\n",
"obj = IDPPSolver.from_endpoints(endpoints=[init_struct, final_struct], nimages=3, sort_tol=1.0)\n",
"new_path = obj.run(maxiter=5000, tol=1e-5, gtol=1e-3, species=[\"Li\"])"
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/neb_path_mapping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
"source": [
"# Get migration paths through the material of interest using the MigrationGraph hop data\n",
"paths = []\n",
"for u, path in mg.get_path():\n",
"for _u, path in mg.get_path():\n",
" paths.append(path)"
]
},
Expand Down
23 changes: 11 additions & 12 deletions examples/probability_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@
"from pymatgen.analysis.diffusion.aimd.pathway import ProbabilityDensityAnalysis\n",
"from pymatgen.core import Structure\n",
"\n",
"#First prepare the structure and ionic trajectories files\n",
"# First prepare the structure and ionic trajectories files\n",
"trajectories = np.load(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_trajectories.npy\")\n",
"structure = Structure.from_file(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4.cif\", False)\n",
"\n",
"#ProbabilityDensityAnalysis object\n",
"# ProbabilityDensityAnalysis object\n",
"pda = ProbabilityDensityAnalysis(structure, trajectories, interval=0.5)\n",
"#Save probability distribution to a CHGCAR-like file\n",
"# Save probability distribution to a CHGCAR-like file\n",
"pda.to_chgcar(filename=\"CHGCAR_new.vasp\")\n",
"\n",
"print(\"Maximum: %s, Minimum: %s\" % (pda.Pr.max(), pda.Pr.min()))\n",
"print(f\"Maximum: {pda.Pr.max()}, Minimum: {pda.Pr.min()}\")\n",
"# \\int P(r)d^3r = 1\n",
"print(\"Total probability: %s\" % np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0]/pda.lens[1]/pda.lens[2]))\n"
"print(f\"Total probability: {np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0]/pda.lens[1]/pda.lens[2])}\")"
]
},
{
Expand Down Expand Up @@ -76,20 +76,19 @@
"\n",
"from pymatgen.analysis.diffusion.analyzer import DiffusionAnalyzer\n",
"\n",
"#ProbabilityDensityAnalysis object\n",
"filename=\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_pda.json\"\n",
"# ProbabilityDensityAnalysis object\n",
"filename = \"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_pda.json\"\n",
"\n",
"data = json.load(open(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_pda.json\"))\n",
"diff_analyzer = DiffusionAnalyzer.from_dict(data)\n",
"\n",
"pda = ProbabilityDensityAnalysis.from_diffusion_analyzer(diff_analyzer, interval=0.5,\n",
" species=(\"Na\", \"Li\"))\n",
"#Save probability distribution to a CHGCAR-like file\n",
"pda = ProbabilityDensityAnalysis.from_diffusion_analyzer(diff_analyzer, interval=0.5, species=(\"Na\", \"Li\"))\n",
"# Save probability distribution to a CHGCAR-like file\n",
"pda.to_chgcar(filename=\"CHGCAR_new2.vasp\")\n",
"\n",
"print(\"Maximum: %s, Minimum: %s\" % (pda.Pr.max(), pda.Pr.min()))\n",
"print(f\"Maximum: {pda.Pr.max()}, Minimum: {pda.Pr.min()}\")\n",
"# \\int P(r)d^3r = 1\n",
"print(\"Total probability: %s\" % np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0]/pda.lens[1]/pda.lens[2]))\n"
"print(f\"Total probability: {np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0]/pda.lens[1]/pda.lens[2])}\")"
]
}
],
Expand Down
31 changes: 17 additions & 14 deletions examples/radial_distribution_function.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"structure_list = []\n",
"for i, s in enumerate(obj.get_drift_corrected_structures()):\n",
" structure_list.append(s)\n",
" if i == 9: break"
" if i == 9:\n",
" break"
]
},
{
Expand All @@ -53,12 +54,11 @@
"outputs": [],
"source": [
"rdf_func = RadialDistributionFunction.from_species(\n",
" structures=structure_list, ngrid=101, rmax=10.0, cell_range=1,\n",
" sigma=0.2, species=[\"Na\"], reference_species=[\"S\"])\n",
" structures=structure_list, ngrid=101, rmax=10.0, cell_range=1, sigma=0.2, species=[\"Na\"], reference_species=[\"S\"]\n",
")\n",
"\n",
"# fewer parameters in new implementations\n",
"rdf_func_faster = RadialDistributionFunctionFast(structures=structure_list,\n",
" ngrid=101, rmax=10.0, sigma=0.2)"
"rdf_func_faster = RadialDistributionFunctionFast(structures=structure_list, ngrid=101, rmax=10.0, sigma=0.2)"
]
},
{
Expand Down Expand Up @@ -224,7 +224,6 @@
}
],
"source": [
"\n",
"r, rdf_na_p_s = rdf_func_faster.get_rdf(\"S\", [\"Na\", \"P\", \"S\"])\n",
"r, rdf_na = rdf_func_faster.get_rdf(\"S\", [\"Na\"])\n",
"r, rdf_p = rdf_func_faster.get_rdf(\"S\", [\"P\"])\n",
Expand All @@ -234,8 +233,7 @@
"plt.plot(r, rdf_na, label=\"S-Na\")\n",
"plt.plot(r, rdf_p, label=\"S-P\")\n",
"plt.plot(r, rdf_s, label=\"S-S\")\n",
"plt.legend()\n",
"\n"
"plt.legend()"
]
},
{
Expand Down Expand Up @@ -268,8 +266,14 @@
],
"source": [
"rdf_func = RadialDistributionFunction.from_species(\n",
" structures=structure_list, ngrid=101, rmax=10.0, cell_range=1,\n",
" sigma=0.2, species=[\"Na\",\"P\", \"S\"], reference_species=[\"S\"])\n",
" structures=structure_list,\n",
" ngrid=101,\n",
" rmax=10.0,\n",
" cell_range=1,\n",
" sigma=0.2,\n",
" species=[\"Na\", \"P\", \"S\"],\n",
" reference_species=[\"S\"],\n",
")\n",
"\n",
"plt.plot(rdf_func.interval, rdf_func.rdf)\n",
"plt.ylim([-0.2, 6.2])"
Expand All @@ -292,8 +296,8 @@
"%%timeit -n 1\n",
"\n",
"rdf_func = RadialDistributionFunction.from_species(\n",
" structures=structure_list, ngrid=101, rmax=10.0, cell_range=1,\n",
" sigma=0.2, species=[\"Na\"], reference_species=[\"S\"])"
" structures=structure_list, ngrid=101, rmax=10.0, cell_range=1, sigma=0.2, species=[\"Na\"], reference_species=[\"S\"]\n",
")"
]
},
{
Expand All @@ -312,8 +316,7 @@
"source": [
"%%timeit -n 1\n",
"# fewer parameters in new implementations\n",
"rdf_func_faster = RadialDistributionFunctionFast(structures=structure_list,\n",
" ngrid=101, rmax=10.0, sigma=0.2)"
"rdf_func_faster = RadialDistributionFunctionFast(structures=structure_list, ngrid=101, rmax=10.0, sigma=0.2)"
]
}
],
Expand Down
8 changes: 5 additions & 3 deletions examples/van_hove.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@
"\n",
"new_obj = DiffusionAnalyzer.from_dict(data)\n",
"\n",
"vhfunc = VanHoveAnalysis(diffusion_analyzer=new_obj, avg_nsteps=5, ngrid=101, rmax=10.0,\n",
" step_skip=5, sigma=0.1, species = [\"Li\", \"Na\"])\n",
"vhfunc = VanHoveAnalysis(\n",
" diffusion_analyzer=new_obj, avg_nsteps=5, ngrid=101, rmax=10.0, step_skip=5, sigma=0.1, species=[\"Li\", \"Na\"]\n",
")\n",
"\n",
"vhfunc.get_3d_plot(mode=\"self\")\n",
"vhfunc.get_3d_plot(mode=\"distinct\")"
Expand Down Expand Up @@ -141,7 +142,8 @@
"structure_list = []\n",
"for i, s in enumerate(new_obj.get_drift_corrected_structures()):\n",
" structure_list.append(s)\n",
" if i == 9: break\n",
" if i == 9:\n",
" break\n",
"\n",
"# Compute and plot RDF for Na and S\n",
"species = [\"Na\", \"S\"]\n",
Expand Down
4 changes: 2 additions & 2 deletions pymatgen/analysis/diffusion/aimd/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def from_species(
@property
def coordination_number(self) -> np.ndarray:
"""
returns running coordination number.
Returns running coordination number.

Returns:
numpy array
Expand Down Expand Up @@ -456,7 +456,7 @@ def get_coordination_number(
is_average: bool = True,
) -> tuple[np.ndarray, list]:
"""
returns running coordination number.
Returns running coordination number.

Args:
ref_species (list of species or just single specie str): the reference species.
Expand Down
6 changes: 3 additions & 3 deletions pymatgen/analysis/diffusion/neb/full_path_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def get_structure_from_entries(

def _get_pos_and_migration_hop(self, u: int, v: int, w: int) -> None:
"""
insert a single MigrationHop object on a graph edge
Insert a single MigrationHop object on a graph edge
Args:
u (int): index of initial node
v (int): index of final node
Expand Down Expand Up @@ -362,7 +362,7 @@ def assign_cost_to_graph(self, cost_keys: list | None = None) -> None:

def get_path(self, max_val: float = 100000, flip_hops: bool = True) -> Generator:
"""
obtain a pathway through the material using hops that are in the current graph
Obtain a pathway through the material using hops that are in the current graph
Basic idea:
Get an endpoint p1 in the graph that is outside the current unit cell
Ask the graph for a pathway that connects to p1 from either within the (0,0,0) cell
Expand Down Expand Up @@ -692,7 +692,7 @@ def populate_edges_with_chg_density_info(self, tube_radius: float = 1) -> None:

def get_least_chg_path(self) -> list:
"""
obtain an intercolating pathway through the material that has the least amount of charge
Obtain an intercolating pathway through the material that has the least amount of charge
Returns:
list of hops.
"""
Expand Down
Loading