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.ci] pre-commit autoupdate #211

Open
wants to merge 2 commits into
base: main
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.4
rev: v0.7.4
hooks:
# Run the linter.
- id: ruff
args: [ --fix, --unsafe-fixes]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.13.0
hooks:
- id: mypy
files: ^pymatgen/
Expand All @@ -20,7 +20,7 @@ repos:
- tokenize-rt==4.1.0
- types-pkg_resources==0.1.2
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
name: codespell
Expand All @@ -33,7 +33,7 @@ repos:
--skip, "*.ipynb,./tests,*paper*",
]
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
rev: 0.8.1
hooks:
- id: nbstripout
args: [
Expand Down
7 changes: 2 additions & 5 deletions docs/source/content/defect-finder.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
"from pathlib import Path\n",
"\n",
"import numpy as np\n",
"from pymatgen.io.vasp import Locpot\n",
"\n",
"TEST_FILES = Path(\"../../../tests/test_files\")\n",
"import glob\n",
"\n",
"from pymatgen.analysis.defects.finder import DefectSiteFinder\n",
"from pymatgen.core.structure import Structure\n",
Expand All @@ -37,11 +35,10 @@
"finder = DefectSiteFinder()\n",
"\n",
"for q in range(-1, 3):\n",
" fname = f\"{str(TEST_FILES)}/v_N_GaN/q={q}/CONTCAR.gz\"\n",
" fname = f\"{TEST_FILES!s}/v_N_GaN/q={q}/CONTCAR.gz\"\n",
" struct = Structure.from_file(fname)\n",
" fpos = finder.get_defect_fpos(defect_structure=struct, base_structure=base_struct)\n",
" fpos -= np.round(fpos)\n",
" print(fpos)"
" fpos -= np.round(fpos)"
]
},
{
Expand Down
20 changes: 8 additions & 12 deletions docs/source/content/defining-defects.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"if (\n",
" bulk.lattice == bulk.get_primitive_structure().lattice\n",
"): # check that you have the primitive structure\n",
" print(\"The bulk unit cell is the unique primitive WS cell\")"
" pass"
]
},
{
Expand Down Expand Up @@ -92,7 +92,7 @@
"mg_ga_defect0 = Substitution(structure=bulk, site=mg_site0)\n",
"mg_ga_defect1 = Substitution(structure=bulk, site=mg_site1)\n",
"if mg_ga_defect0 == mg_ga_defect1:\n",
" print(\"The two Mg_Ga defects are equivalent.\")"
" pass"
]
},
{
Expand Down Expand Up @@ -125,14 +125,10 @@
"vac_defect1 = Vacancy(structure=bulk, site=n_site0)\n",
"vac_defect2 = Vacancy(structure=bulk, site=n_site1)\n",
"if vac_defect0 != vac_defect1:\n",
" print(\n",
" f\"The two vacancies {vac_defect0.name} and {vac_defect1.name} are not equivalent.\"\n",
" )\n",
" pass\n",
"\n",
"if vac_defect2 == vac_defect1:\n",
" print(\n",
" f\"The two vacancies {vac_defect2.name} and {vac_defect1.name} are equivalent.\"\n",
" )"
" pass"
]
},
{
Expand Down Expand Up @@ -260,8 +256,8 @@
"\n",
"chgcar = Chgcar.from_file(TEST_FILES / \"CHGCAR.Fe3O4.vasp\")\n",
"cig = ChargeInterstitialGenerator()\n",
"for defect in cig.generate(chgcar, insert_species=[\"H\"]):\n",
" print(defect)"
"for _defect in cig.generate(chgcar, insert_species=[\"H\"]):\n",
" pass"
]
},
{
Expand All @@ -279,8 +275,8 @@
},
"outputs": [],
"source": [
"for defect in generate_all_native_defects(chgcar):\n",
" print(defect)"
"for _defect in generate_all_native_defects(chgcar):\n",
" pass"
]
},
{
Expand Down
12 changes: 6 additions & 6 deletions docs/source/content/formation-energy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
"outputs": [],
"source": [
"import warnings\n",
"\n",
"from monty.serialization import loadfn\n",
"from pymatgen.analysis.defects.thermo import FormationEnergyDiagram\n",
"from pymatgen.io.vasp import Vasprun\n",
"\n",
"warnings.filterwarnings(\"ignore\")\n",
"\n",
Expand Down Expand Up @@ -129,10 +129,9 @@
"metadata": {},
"outputs": [],
"source": [
"for i, p in enumerate(fed.chempot_limits):\n",
" print(f\"Limits for the chemical potential changes for point {i}\")\n",
" for k,v in p.items():\n",
" print(f\"Δμ_{k} = {v:.2f} eV\")"
"for _i, p in enumerate(fed.chempot_limits):\n",
" for _k, _v in p.items():\n",
" pass"
]
},
{
Expand Down Expand Up @@ -164,10 +163,11 @@
"outputs": [],
"source": [
"from pymatgen.analysis.defects.corrections.freysoldt import plot_plnr_avg\n",
"\n",
"plot_data = fed.defect_entries[1].corrections_metadata[\"freysoldt\"][\"plot_data\"]\n",
"plot_plnr_avg(plot_data[0], title=\"Lattice Direction 1\")\n",
"plot_plnr_avg(plot_data[1], title=\"Lattice Direction 2\")\n",
"plot_plnr_avg(plot_data[2], title=\"Lattice Direction 3\")\n"
"plot_plnr_avg(plot_data[2], title=\"Lattice Direction 3\")"
]
}
],
Expand Down
16 changes: 6 additions & 10 deletions docs/source/content/freysoldt-correction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,14 @@
" defect_structure=defect_locpot.structure, base_structure=bulk_locpot.structure\n",
" )\n",
" center -= np.round(center)\n",
" print(f\"Computing Freysoldt Correction for: q={q}\")\n",
" print(f\"center={center}\")\n",
" freysoldt_results[q] = get_freysoldt_correction(\n",
" q=q,\n",
" dielectric=5,\n",
" bulk_locpot=bulk_locpot,\n",
" defect_locpot=defect_locpot,\n",
" defect_frac_coords=center,\n",
" )\n",
" align = np.mean(list(freysoldt_results[q].metadata[\"alignments\"].values()))\n",
" print(f\"alignment correction: {align}\")\n"
" align = np.mean(list(freysoldt_results[q].metadata[\"alignments\"].values()))"
]
},
{
Expand All @@ -103,7 +100,7 @@
"metadata": {},
"outputs": [],
"source": [
"def plot_sxd_output(q, direction, C, ax):\n",
"def plot_sxd_output(q, direction, C, ax) -> None:\n",
" \"\"\"Read the vline-eV-a#.dat files computed by the `sxdefectalign` program.\n",
"\n",
" Args:\n",
Expand All @@ -114,7 +111,7 @@
" \"\"\"\n",
" v_line_file = DEFECT_DIR / f\"q={q}/vline-eV-a{direction}.dat\"\n",
" # split the file into blocks based on the location of the string \"&\"\n",
" with open(v_line_file, \"r\") as f:\n",
" with open(v_line_file) as f:\n",
" blocks = f.read().split(\"&\")\n",
"\n",
" # convert each block into a list of lines and convert to a numpy array\n",
Expand All @@ -134,7 +131,7 @@
" ax.legend()\n",
"\n",
"\n",
"def comparison_plots(q):\n",
"def comparison_plots(q) -> None:\n",
" \"\"\"\"\"\"\n",
" fig, axs = plt.subplots(3, 2, figsize=(15, 15), sharey=True)\n",
" for direction in range(3):\n",
Expand Down Expand Up @@ -210,7 +207,7 @@
"outputs": [],
"source": [
"def get_sxd_result(q):\n",
" \"\"\"Read the output of sxdefectalign\"\"\"\n",
" \"\"\"Read the output of sxdefectalign.\"\"\"\n",
" fname = str(DEFECT_DIR / f\"q={q}/corr_align.out\")\n",
" gen = reverse_readfile(fname)\n",
" next(gen)\n",
Expand All @@ -226,8 +223,7 @@
"source": [
"for q in range(-1, 3):\n",
" python_res = freysoldt_results[q].correction_energy\n",
" sxd_res = get_sxd_result(q)\n",
" print(f\"python: {python_res:0.4f} / sxdefectalign: {sxd_res:0.4f}\")"
" sxd_res = get_sxd_result(q)"
]
}
],
Expand Down
24 changes: 8 additions & 16 deletions docs/source/content/nonradiative.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
"source": [
"# disable warnings\n",
"import warnings\n",
"\n",
"warnings.filterwarnings(\"ignore\", category=UserWarning)\n",
"from pathlib import Path\n",
"\n",
"import numpy as np\n",
"from matplotlib import pyplot as plt\n",
"from pymatgen.analysis.defects.ccd import HarmonicDefect, get_SRH_coefficient"
Expand Down Expand Up @@ -63,12 +65,6 @@
"hd0 = HarmonicDefect.from_directories(\n",
" directories=dirs01,\n",
" store_bandstructure=True,\n",
")\n",
"print(f\"The relaxed structure is in dirs01[{hd0.relaxed_index}]\")\n",
"print(hd0)\n",
"print(\n",
" f\"The spin channel ({hd0.spin}) is also automaticalliy determined by the \"\n",
" \"IPR, by taking the spin channel who's defect states have the lowest average IPR across the different k-points.\"\n",
")"
]
},
Expand Down Expand Up @@ -184,9 +180,7 @@
"outputs": [],
"source": [
"wswq_dir = TEST_FILES / \"ccd_0_-1\" / \"wswqs\"\n",
"print(f\"The parsed WSWQ files are: {[f.name for f in wswq_dir.glob('WSWQ*')]}\")\n",
"hd0.read_wswqs(TEST_FILES / \"ccd_0_-1\" / \"wswqs\")\n",
"print(f\"Parsed {len(hd0.wswqs)} WSWQ files.\")\n"
"hd0.read_wswqs(TEST_FILES / \"ccd_0_-1\" / \"wswqs\")"
]
},
{
Expand All @@ -205,11 +199,7 @@
"metadata": {},
"outputs": [],
"source": [
"print(f\"The automatically determined defect electronic states are: {hd0.defect_band} \"\n",
" \"(with [band, k-point, spin] indexing).\")\n",
"epME = hd0.get_elph_me(defect_state=(138, 1, 1))\n",
"print(f\"The resulting array of shape {epME.shape} contains the matrix elements from the \"\n",
" \"defect state to all other states at the same k-point.\")\n"
"epME = hd0.get_elph_me(defect_state=(138, 1, 1))"
]
},
{
Expand All @@ -233,7 +223,7 @@
"hd1 = HarmonicDefect.from_directories(\n",
" directories=dirs10,\n",
" store_bandstructure=True,\n",
")\n"
")"
]
},
{
Expand All @@ -252,7 +242,9 @@
"outputs": [],
"source": [
"T = np.linspace(100, 1000, 20)\n",
"srh_c = get_SRH_coefficient(initial_state=hd0, final_state=hd1, defect_state=(138, 1, 1), T=T, dE=0.3)\n",
"srh_c = get_SRH_coefficient(\n",
" initial_state=hd0, final_state=hd1, defect_state=(138, 1, 1), T=T, dE=0.3\n",
")\n",
"plt.plot(T, srh_c)\n",
"plt.xlabel(\"Temperature [K]\")\n",
"plt.ylabel(\"SRH coefficient [cm$^{-3}$s$^{-1}$]\");"
Expand Down
Loading
Loading