From b4b4e4a31ada84b8108739c2de6b5a1415865620 Mon Sep 17 00:00:00 2001 From: "J. George" Date: Wed, 1 May 2024 20:56:27 +0200 Subject: [PATCH 01/25] Update pyproject.toml --- pyproject.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e3cd1659..1e79aef2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,13 +22,14 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Development Status :: 5 - Production/Stable", "Intended Audience :: Science/Research", "Operating System :: OS Independent", ] -requires-python = ">=3.9,<3.12" +requires-python = ">=3.9,<3.13" dependencies = [ - "pymatgen>=2024.4.13", + "pymatgen>=2024.5.1", "numpy", "typing", ] From 822201e282b10995ea870d4e2f699ad383ff8906 Mon Sep 17 00:00:00 2001 From: "J. George" Date: Wed, 1 May 2024 20:58:38 +0200 Subject: [PATCH 02/25] Update python-package.yml --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 26276eed..81ced310 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -28,7 +28,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] split: [1, 2, 3, 4, 5, 6] steps: From 6b11aebd1159d100def814032b490eeb671a2149 Mon Sep 17 00:00:00 2001 From: "J. George" Date: Wed, 1 May 2024 21:42:45 +0200 Subject: [PATCH 03/25] replace with importlib --- lobsterpy/plotting/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lobsterpy/plotting/__init__.py b/lobsterpy/plotting/__init__.py index 846b6c7c..43d6eb5c 100644 --- a/lobsterpy/plotting/__init__.py +++ b/lobsterpy/plotting/__init__.py @@ -6,6 +6,7 @@ from __future__ import annotations import typing +from importlib import resources from itertools import cycle from typing import TYPE_CHECKING, Any @@ -13,7 +14,6 @@ import numpy as np import plotly.graph_objs as go from matplotlib import pyplot as plt -from pkg_resources import resource_filename from pymatgen.core import Structure from pymatgen.electronic_structure.cohp import Cohp, CompleteCohp, IcohpCollection from pymatgen.electronic_structure.core import Spin @@ -24,7 +24,7 @@ from lobsterpy.cohp.analyze import Analysis from lobsterpy.plotting import layout_dicts as ld -base_style = resource_filename("lobsterpy.plotting", "lobsterpy_base.mplstyle") +base_style = resources.as_file("lobsterpy.plotting", "lobsterpy_base.mplstyle") def get_style_list( From cbb3ff9e5d95eab13a288f869a8154fb11e7e60b Mon Sep 17 00:00:00 2001 From: "J. George" Date: Wed, 1 May 2024 21:45:26 +0200 Subject: [PATCH 04/25] Update __init__.py --- lobsterpy/plotting/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lobsterpy/plotting/__init__.py b/lobsterpy/plotting/__init__.py index 43d6eb5c..8d48c2fa 100644 --- a/lobsterpy/plotting/__init__.py +++ b/lobsterpy/plotting/__init__.py @@ -24,7 +24,7 @@ from lobsterpy.cohp.analyze import Analysis from lobsterpy.plotting import layout_dicts as ld -base_style = resources.as_file("lobsterpy.plotting", "lobsterpy_base.mplstyle") +base_style = resources.path("lobsterpy.plotting", "lobsterpy_base.mplstyle") def get_style_list( From 998e216307ed69dde80513799fca6f6fe60347e2 Mon Sep 17 00:00:00 2001 From: "J. George" Date: Wed, 1 May 2024 22:42:24 +0200 Subject: [PATCH 05/25] Update __init__.py --- lobsterpy/plotting/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lobsterpy/plotting/__init__.py b/lobsterpy/plotting/__init__.py index 8d48c2fa..5b141dd3 100644 --- a/lobsterpy/plotting/__init__.py +++ b/lobsterpy/plotting/__init__.py @@ -4,9 +4,9 @@ """Here classes and functions to plot Lobster outputs are provided.""" from __future__ import annotations +from pathlib import Path import typing -from importlib import resources from itertools import cycle from typing import TYPE_CHECKING, Any @@ -24,7 +24,7 @@ from lobsterpy.cohp.analyze import Analysis from lobsterpy.plotting import layout_dicts as ld -base_style = resources.path("lobsterpy.plotting", "lobsterpy_base.mplstyle") +base_style = Path(__file__).absolute().parent / "lobsterpy_base.mplstyle" def get_style_list( From e5afbd7fdb9ebe1f56b4d2c20ffad4bd6d1292c7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 20:42:45 +0000 Subject: [PATCH 06/25] pre-commit auto-fixes --- lobsterpy/plotting/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lobsterpy/plotting/__init__.py b/lobsterpy/plotting/__init__.py index 5b141dd3..c2690388 100644 --- a/lobsterpy/plotting/__init__.py +++ b/lobsterpy/plotting/__init__.py @@ -4,10 +4,10 @@ """Here classes and functions to plot Lobster outputs are provided.""" from __future__ import annotations -from pathlib import Path import typing from itertools import cycle +from pathlib import Path from typing import TYPE_CHECKING, Any import matplotlib as mpl From fb4d27ba77c63fdbe6b7b15e1212c60490336fbc Mon Sep 17 00:00:00 2001 From: "J. George" Date: Wed, 1 May 2024 22:52:58 +0200 Subject: [PATCH 07/25] Update __init__.py --- lobsterpy/plotting/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lobsterpy/plotting/__init__.py b/lobsterpy/plotting/__init__.py index c2690388..1efbd18e 100644 --- a/lobsterpy/plotting/__init__.py +++ b/lobsterpy/plotting/__init__.py @@ -7,7 +7,6 @@ import typing from itertools import cycle -from pathlib import Path from typing import TYPE_CHECKING, Any import matplotlib as mpl @@ -24,8 +23,6 @@ from lobsterpy.cohp.analyze import Analysis from lobsterpy.plotting import layout_dicts as ld -base_style = Path(__file__).absolute().parent / "lobsterpy_base.mplstyle" - def get_style_list( no_base_style: bool = False, @@ -43,7 +40,13 @@ def get_style_list( :param kwargs: matplotlib-style sheet keyword arguments """ - base = [] if no_base_style else [base_style] + + if no_base_style: + base = [] + else: + ref = importlib_resources.files('lobsterpy.plotting') / 'lobsterpy_base.mplstyle' + with importlib_resources.as_file(ref) as path: + base = [path] if styles is None: styles = [] From c314afefc44e79c54c0616c7203cffb6a0c84c7a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 20:53:12 +0000 Subject: [PATCH 08/25] pre-commit auto-fixes --- lobsterpy/plotting/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lobsterpy/plotting/__init__.py b/lobsterpy/plotting/__init__.py index 1efbd18e..a3ce049f 100644 --- a/lobsterpy/plotting/__init__.py +++ b/lobsterpy/plotting/__init__.py @@ -40,11 +40,10 @@ def get_style_list( :param kwargs: matplotlib-style sheet keyword arguments """ - if no_base_style: - base = [] + base = [] else: - ref = importlib_resources.files('lobsterpy.plotting') / 'lobsterpy_base.mplstyle' + ref = importlib_resources.files("lobsterpy.plotting") / "lobsterpy_base.mplstyle" with importlib_resources.as_file(ref) as path: base = [path] if styles is None: From 8e8a6172db79d4ccaa0ecaa6a10d61829cc26508 Mon Sep 17 00:00:00 2001 From: "J. George" Date: Wed, 1 May 2024 22:55:35 +0200 Subject: [PATCH 09/25] Update __init__.py --- lobsterpy/plotting/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lobsterpy/plotting/__init__.py b/lobsterpy/plotting/__init__.py index a3ce049f..321b7423 100644 --- a/lobsterpy/plotting/__init__.py +++ b/lobsterpy/plotting/__init__.py @@ -6,6 +6,7 @@ from __future__ import annotations import typing +from importlib_resources import files, as_file from itertools import cycle from typing import TYPE_CHECKING, Any @@ -43,8 +44,8 @@ def get_style_list( if no_base_style: base = [] else: - ref = importlib_resources.files("lobsterpy.plotting") / "lobsterpy_base.mplstyle" - with importlib_resources.as_file(ref) as path: + ref = files("lobsterpy.plotting") / "lobsterpy_base.mplstyle" + with as_file(ref) as path: base = [path] if styles is None: styles = [] From 97711615d07ceb229eb3b1f4f8547b4ab06baa6c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 20:55:51 +0000 Subject: [PATCH 10/25] pre-commit auto-fixes --- lobsterpy/plotting/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lobsterpy/plotting/__init__.py b/lobsterpy/plotting/__init__.py index 321b7423..e490c07f 100644 --- a/lobsterpy/plotting/__init__.py +++ b/lobsterpy/plotting/__init__.py @@ -6,13 +6,13 @@ from __future__ import annotations import typing -from importlib_resources import files, as_file from itertools import cycle from typing import TYPE_CHECKING, Any import matplotlib as mpl import numpy as np import plotly.graph_objs as go +from importlib_resources import as_file, files from matplotlib import pyplot as plt from pymatgen.core import Structure from pymatgen.electronic_structure.cohp import Cohp, CompleteCohp, IcohpCollection From ff2c88846c906a0d9ec22564dc9d3010a83b9969 Mon Sep 17 00:00:00 2001 From: JaGeo Date: Thu, 2 May 2024 16:16:40 +0200 Subject: [PATCH 11/25] Fix pathlib --- docs/tutorial/tutorial.ipynb | 160 ++++++++++++++++----------------- lobsterpy/plotting/__init__.py | 7 +- 2 files changed, 83 insertions(+), 84 deletions(-) diff --git a/docs/tutorial/tutorial.ipynb b/docs/tutorial/tutorial.ipynb index 99eac9c2..4bfce366 100644 --- a/docs/tutorial/tutorial.ipynb +++ b/docs/tutorial/tutorial.ipynb @@ -48,14 +48,14 @@ "metadata": { "hide_input": false }, - "outputs": [], "source": [ "from pathlib import Path\n", "from lobsterpy.cohp.analyze import Analysis\n", "from lobsterpy.cohp.describe import Description\n", "import warnings\n", "warnings.filterwarnings('ignore')" - ] + ], + "outputs": [] }, { "cell_type": "code", @@ -66,11 +66,11 @@ "remove-cell" ] }, - "outputs": [], "source": [ "# Directory of your VASP and Lobster computations\n", "directory = Path(\".\") / \"..\" / \"..\" / \"tests\" / \"test_data\" / \"CdF_comp_range\"" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -88,7 +88,6 @@ "execution_count": null, "id": "2ca066a3", "metadata": {}, - "outputs": [], "source": [ "# Initialize Analysis object\n", "analyse = Analysis(\n", @@ -98,30 +97,31 @@ " path_to_charge=directory / \"CHARGE.lobster.gz\",\n", " which_bonds=\"cation-anion\",\n", ")" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "87f41407", "metadata": {}, - "outputs": [], "source": [ "# Initialize Description object and to get text description of the analysis\n", "describe = Description(analysis_object=analyse)\n", "describe.write_description()" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "6a0e3916", "metadata": {}, - "outputs": [], "source": [ "# Get static plots for detected relevant bonds\n", "describe.plot_cohps(ylim=[-10, 2], xlim=[-4, 4])" - ] + ], + "outputs": [] }, { "cell_type": "code", @@ -132,14 +132,14 @@ "remove-output" ] }, - "outputs": [], "source": [ "# Get interactive plots of relevant bonds, \n", "\n", "# Setting label_resolved arg to True will plot each COHP curve separately, alongside summed COHP for the bonds.\n", "fig = describe.plot_interactive_cohps(label_resolved=True, hide=True)\n", "fig.show(renderer='notebook')" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -156,33 +156,33 @@ "execution_count": null, "id": "3c695d06", "metadata": {}, - "outputs": [], "source": [ "# Dict summarizing the automatic analysis results\n", "analyse.condensed_bonding_analysis" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "b079043b", "metadata": {}, - "outputs": [], "source": [ "# Dict with bonds identified\n", "analyse.final_dict_bonds" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "bcab3c31", "metadata": {}, - "outputs": [], "source": [ "# Dict with ions and their co-ordination environments\n", "analyse.final_dict_ions" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -229,7 +229,6 @@ "execution_count": null, "id": "ae5c791f", "metadata": {}, - "outputs": [], "source": [ "analyse = Analysis(\n", " path_to_poscar=directory / \"POSCAR.gz\",\n", @@ -240,18 +239,19 @@ " orbital_resolved=True,\n", " orbital_cutoff=0.03,\n", ")" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "468a2478", "metadata": {}, - "outputs": [], "source": [ "# Access the dict summarizing the results including orbital-wise analysis data \n", "analyse.condensed_bonding_analysis" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -276,12 +276,12 @@ "execution_count": null, "id": "2df4b44a", "metadata": {}, - "outputs": [], "source": [ "# Initialize the Description object\n", "describe = Description(analysis_object=analyse)\n", "describe.write_description()" - ] + ], + "outputs": [] }, { "cell_type": "code", @@ -292,12 +292,12 @@ "remove-output" ] }, - "outputs": [], "source": [ "# Automatic interactive plots\n", "fig = describe.plot_interactive_cohps(orbital_resolved=True, ylim=[-15,5], hide=True)\n", "fig.show(renderer='notebook')" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -332,11 +332,11 @@ "remove-cell" ] }, - "outputs": [], "source": [ "# Directory to your VASP and Lobster computations\n", "directory = Path(\".\") / \"..\" / \"..\" / \"tests\" / \"test_data\" / \"K3Sb\"" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -354,7 +354,6 @@ "execution_count": null, "id": "87a8eb35", "metadata": {}, - "outputs": [], "source": [ "# Get calculation quality summary dict\n", "calc_quality_K3Sb = Analysis.get_lobster_calc_quality_summary(\n", @@ -372,21 +371,22 @@ " n_bins=256,\n", " )\n", "calc_quality_K3Sb" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "8bca8893", "metadata": {}, - "outputs": [], "source": [ "# Get a text description from calculation quality summary dictionary\n", "calc_quality_k3sb_des = Description.get_calc_quality_description(\n", " calc_quality_K3Sb\n", " )\n", "Description.write_calc_quality_description(calc_quality_k3sb_des)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -401,12 +401,12 @@ "execution_count": null, "id": "240ae59d", "metadata": {}, - "outputs": [], "source": [ "from matplotlib import style\n", "from pymatgen.io.lobster import Doscar\n", "from lobsterpy.plotting import InteractiveCohpPlotter, IcohpDistancePlotter, PlainCohpPlotter, PlainDosPlotter, get_style_list" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -431,7 +431,6 @@ "execution_count": null, "id": "3da81099", "metadata": {}, - "outputs": [], "source": [ "# Using PlainCohpPlotter to get static plots of relevant bonds from Analysis object\n", "\n", @@ -442,7 +441,8 @@ " cohp = analyse.chemenv.completecohp.get_summed_cohp_by_label_list(label_list=label_list)\n", " cohp_plot_static.add_cohp(plot_label, cohp)\n", "cohp_plot_static.get_plot(ylim=[-15,2]);" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -459,7 +459,6 @@ "execution_count": null, "id": "b01bf48a", "metadata": {}, - "outputs": [], "source": [ "# Using PlainCohpPlotter to get static plots of relevant orbitals COHPs from Analysis object\n", "\n", @@ -473,28 +472,29 @@ " orbital_list=[orb]*len(label_list))\n", " cohp_plot_static.add_cohp(orb, cohp)\n", "cohp_plot_static.get_plot(ylim=[-15,2]);" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "866cd67a", "metadata": {}, - "outputs": [], "source": [ "# Using interactive plotter to add relevant cohps\n", "interactive_cohp_plot = InteractiveCohpPlotter()" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "60f64578", "metadata": {}, - "outputs": [], "source": [ "interactive_cohp_plot.add_all_relevant_cohps(analyse=analyse, label_resolved=False,orbital_resolved=True,suffix='')" - ] + ], + "outputs": [] }, { "cell_type": "code", @@ -505,11 +505,11 @@ "remove-output" ] }, - "outputs": [], "source": [ "fig = interactive_cohp_plot.get_plot()\n", "fig.show(renderer='notebook')" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -538,13 +538,13 @@ "remove-cell" ] }, - "outputs": [], "source": [ "# Load Lobster DOS\n", "directory = Path(\".\") / \"..\" / \"..\" / \"tests\" / \"test_data\" / \"NaCl_comp_range\"\n", "dos = Doscar(doscar=directory / 'DOSCAR.lobster.gz',\n", " structure_file=directory / 'POSCAR.gz')" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -574,7 +574,6 @@ "metadata": { "scrolled": false }, - "outputs": [], "source": [ "style.use('default') # Complete reset the matplotlib figure style\n", "style.use(get_style_list()[0]) # Use the LobsterPy style sheet for the generated plots\n", @@ -584,7 +583,8 @@ "dos_plotter.add_dos_dict(dos_dict=dos.completedos.get_element_dos()) # Add element dos\n", "dos_plotter.add_dos_dict(dos_dict=dos.completedos.get_spd_dos()) # add spd dos\n", "dos_plotter.get_plot(xlim=[-10, 3]);" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -599,12 +599,12 @@ "execution_count": null, "id": "660b35ad", "metadata": {}, - "outputs": [], "source": [ "dos_plotter = PlainDosPlotter(summed=True, stack=False, sigma=0.03)\n", "dos_plotter.add_site_orbital_dos(dos = dos.completedos, site_index=0, orbital='3s')\n", "dos_plotter.get_plot(xlim=[-10, 3]);" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -619,10 +619,10 @@ "execution_count": null, "id": "45988996", "metadata": {}, - "outputs": [], "source": [ "from lobsterpy.structuregraph.graph import LobsterGraph" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -641,7 +641,6 @@ "remove-cell" ] }, - "outputs": [], "source": [ "graph_NaCl_all = LobsterGraph(\n", " path_to_poscar=directory / \"POSCAR.gz\",\n", @@ -655,7 +654,8 @@ " which_bonds=\"all\",\n", " start=None,\n", ")" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -684,20 +684,20 @@ "execution_count": null, "id": "604bfa7e", "metadata": {}, - "outputs": [], "source": [ "graph_NaCl_all.sg.graph.nodes.data() # view node data" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "c77c2b06", "metadata": {}, - "outputs": [], "source": [ "graph_NaCl_all.sg.graph.edges.data() # view edge data" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -730,11 +730,11 @@ "execution_count": null, "id": "8882b3f5", "metadata": {}, - "outputs": [], "source": [ "from lobsterpy.featurize.batch import (BatchCoxxFingerprint, BatchDosFeaturizer,\n", " BatchSummaryFeaturizer, BatchStructureGraphs)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -763,7 +763,6 @@ "remove-cell" ] }, - "outputs": [], "source": [ "# Initialize the batch COXX featurizer \n", "fp_cohp_bonding = BatchCoxxFingerprint(\n", @@ -775,7 +774,8 @@ " n_jobs=3,\n", " fingerprint_for='cohp' # changing this to cobi/coop will result in reading cobicar/coopcar file\n", " )" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -803,22 +803,22 @@ "metadata": { "scrolled": true }, - "outputs": [], "source": [ "# Access the fingerprints dataframe\n", "fp_cohp_bonding.fingerprint_df" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "cafc1f90", "metadata": {}, - "outputs": [], "source": [ "# Get the fingerprints similarity matrix\n", "fp_cohp_bonding.get_similarity_matrix_df()" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -849,7 +849,6 @@ "remove-cell" ] }, - "outputs": [], "source": [ "# Initialize the batch DOS featurizer\n", "batch_dos = BatchDosFeaturizer(path_to_lobster_calcs=directory / \"..\" / \"Featurizer_test_data\" / \"Lobster_calcs\", # path to parent lobster calcs\n", @@ -859,7 +858,8 @@ " fingerprint_type=\"summed_pdos\", # fingerprint type (s,p,d,f, summed_pdos)\n", " n_bins=256,\n", " n_jobs=3,)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -883,22 +883,22 @@ "execution_count": null, "id": "3b958625", "metadata": {}, - "outputs": [], "source": [ "# get the DOS moments df\n", "batch_dos.get_df()" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "b9ad30a1", "metadata": {}, - "outputs": [], "source": [ "# get the DOS fingerprints df\n", "batch_dos.get_fingerprints_df()" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -930,7 +930,6 @@ "remove-cell" ] }, - "outputs": [], "source": [ "# Initialize batch summary featurizer\n", "summary_features = BatchSummaryFeaturizer(\n", @@ -941,7 +940,8 @@ " e_range=[-15, 0],\n", " n_jobs=3,\n", " )" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -968,11 +968,11 @@ "execution_count": null, "id": "1bfad526", "metadata": {}, - "outputs": [], "source": [ "# get summary stats features \n", "summary_features.get_df()" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -999,14 +999,14 @@ "remove-cell" ] }, - "outputs": [], "source": [ "batch_sg = BatchStructureGraphs(path_to_lobster_calcs=directory / \"..\" / \"Featurizer_test_data\" / \"Lobster_calcs\",\n", " add_additional_data_sg=True,\n", " which_bonds='all',\n", " n_jobs=3,\n", " start=None)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -1028,11 +1028,11 @@ "execution_count": null, "id": "9a8178bc", "metadata": {}, - "outputs": [], "source": [ "# get the structure graphs df\n", "batch_sg.get_df()" - ] + ], + "outputs": [] } ], "metadata": { diff --git a/lobsterpy/plotting/__init__.py b/lobsterpy/plotting/__init__.py index e490c07f..d7cbd127 100644 --- a/lobsterpy/plotting/__init__.py +++ b/lobsterpy/plotting/__init__.py @@ -7,12 +7,12 @@ import typing from itertools import cycle +from pathlib import Path from typing import TYPE_CHECKING, Any import matplotlib as mpl import numpy as np import plotly.graph_objs as go -from importlib_resources import as_file, files from matplotlib import pyplot as plt from pymatgen.core import Structure from pymatgen.electronic_structure.cohp import Cohp, CompleteCohp, IcohpCollection @@ -44,9 +44,8 @@ def get_style_list( if no_base_style: base = [] else: - ref = files("lobsterpy.plotting") / "lobsterpy_base.mplstyle" - with as_file(ref) as path: - base = [path] + path = Path(__file__).absolute().parent / "lobsterpy_base.mplstyle" + base = [path] if styles is None: styles = [] From 81afab133e20070d7dc3087d5f7aeb986648850b Mon Sep 17 00:00:00 2001 From: JaGeo Date: Thu, 2 May 2024 16:50:41 +0200 Subject: [PATCH 12/25] make py312 compatible --- lobsterpy/plotting/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lobsterpy/plotting/__init__.py b/lobsterpy/plotting/__init__.py index d7cbd127..bdd6a8a5 100644 --- a/lobsterpy/plotting/__init__.py +++ b/lobsterpy/plotting/__init__.py @@ -44,8 +44,8 @@ def get_style_list( if no_base_style: base = [] else: - path = Path(__file__).absolute().parent / "lobsterpy_base.mplstyle" - base = [path] + # not really happy with this but it works + base = [str(Path(__file__).absolute().parent / "lobsterpy_base.mplstyle")] if styles is None: styles = [] From 94fdfedb636d37a3700ccdbe0e73109887fa2f00 Mon Sep 17 00:00:00 2001 From: JaGeo Date: Thu, 2 May 2024 16:55:57 +0200 Subject: [PATCH 13/25] fix linting --- lobsterpy/plotting/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lobsterpy/plotting/__init__.py b/lobsterpy/plotting/__init__.py index bdd6a8a5..3d715db3 100644 --- a/lobsterpy/plotting/__init__.py +++ b/lobsterpy/plotting/__init__.py @@ -41,11 +41,7 @@ def get_style_list( :param kwargs: matplotlib-style sheet keyword arguments """ - if no_base_style: - base = [] - else: - # not really happy with this but it works - base = [str(Path(__file__).absolute().parent / "lobsterpy_base.mplstyle")] + base = [] if no_base_style else [str(Path(__file__).absolute().parent / "lobsterpy_base.mplstyle")] if styles is None: styles = [] From b655a6e3a0aad3bf4f77e36b276c9eb802622e21 Mon Sep 17 00:00:00 2001 From: JaGeo Date: Thu, 2 May 2024 17:00:56 +0200 Subject: [PATCH 14/25] deactivate flake8 from precommi --- .pre-commit-config.yaml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ae1a9c69..01bbd389 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,19 +29,19 @@ repos: - id: blacken-docs additional_dependencies: [black] exclude: README.md -- repo: https://github.com/pycqa/flake8 - rev: 7.0.0 - hooks: - - id: flake8 - entry: pflake8 - files: lobsterpy/.* - additional_dependencies: - - pyproject-flake8==6.0.0a1 - - flake8-bugbear==22.12.6 - - flake8-typing-imports==1.14.0 - - flake8-docstrings==1.6.0 - - flake8-rst-docstrings==0.3.0 - - flake8-rst==0.8.0 +#- repo: https://github.com/pycqa/flake8 +# rev: 7.0.0 +# hooks: +# - id: flake8 +# entry: pflake8 +# files: lobsterpy/.* +# additional_dependencies: +# - pyproject-flake8==6.0.0a1 +# - flake8-bugbear==22.12.6 +# - flake8-typing-imports==1.14.0 +# - flake8-docstrings==1.6.0 + # - flake8-rst-docstrings==0.3.0 + # - flake8-rst==0.8.0 - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: From d36b1d24c35c0e9662d67b99a847cac78758c9c9 Mon Sep 17 00:00:00 2001 From: JaGeo Date: Thu, 2 May 2024 17:12:32 +0200 Subject: [PATCH 15/25] try to fix last test --- tests/cohp/test_describe.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index 2d0344ee..888993eb 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -371,10 +371,10 @@ def test_warnings(self): dos_comparison=True, bva_comp=False, ) - assert "Consider using DOSCAR.LSO.lobster" in str(w[0].message) - assert "Minimum energy range requested" in str(w[1].message) - assert "Maximum energy range requested" in str(w[2].message) - assert "Input DOS files have very few points" in str(w[3].message) + assert ("Consider using DOSCAR.LSO.lobster" in str(w[0].message)) + assert ("Minimum energy range requested" in str(w[1].message)) + assert ("Maximum energy range requested" in str(w[2].message)) + assert ("Input DOS files have very few points" in str(w[3].message)) calc_des = Description.get_calc_quality_description(calc_quality_warnings) @@ -397,7 +397,7 @@ def test_warnings(self): potcar_symbols=["C"], bva_comp=True, ) - assert "Oxidation states from BVA analyzer cannot" in str(w2[0].message) + assert ("Oxidation states from BVA analyzer cannot" in str(w2[0].message)) calc_des2 = Description.get_calc_quality_description(calc_quality_warnings2) From fa67c1bd20883b0781895ddec21cd903fb8bc5fb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 15:13:22 +0000 Subject: [PATCH 16/25] pre-commit auto-fixes --- tests/cohp/test_describe.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index 888993eb..2d0344ee 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -371,10 +371,10 @@ def test_warnings(self): dos_comparison=True, bva_comp=False, ) - assert ("Consider using DOSCAR.LSO.lobster" in str(w[0].message)) - assert ("Minimum energy range requested" in str(w[1].message)) - assert ("Maximum energy range requested" in str(w[2].message)) - assert ("Input DOS files have very few points" in str(w[3].message)) + assert "Consider using DOSCAR.LSO.lobster" in str(w[0].message) + assert "Minimum energy range requested" in str(w[1].message) + assert "Maximum energy range requested" in str(w[2].message) + assert "Input DOS files have very few points" in str(w[3].message) calc_des = Description.get_calc_quality_description(calc_quality_warnings) @@ -397,7 +397,7 @@ def test_warnings(self): potcar_symbols=["C"], bva_comp=True, ) - assert ("Oxidation states from BVA analyzer cannot" in str(w2[0].message)) + assert "Oxidation states from BVA analyzer cannot" in str(w2[0].message) calc_des2 = Description.get_calc_quality_description(calc_quality_warnings2) From 40318bc1b3a2ed17515fd4554b674807de3afe0e Mon Sep 17 00:00:00 2001 From: JaGeo Date: Thu, 2 May 2024 17:29:47 +0200 Subject: [PATCH 17/25] test assertion --- tests/cohp/test_describe.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index 2d0344ee..c56e643e 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -419,7 +419,8 @@ def test_warnings(self): potcar_symbols=["Be_sv", "Te"], bva_comp=True, ) - assert "Consider rerunning the calc with the minimum basis" in str(w3[0].message) + + assert "Consider rerunning the calc with the minimum basis" in str(w3[0].message) == True calc_des3 = Description.get_calc_quality_description(calc_quality_warnings3) From a74bb7b08a6935f08357dc97bf488c0dfad82b9e Mon Sep 17 00:00:00 2001 From: JaGeo Date: Thu, 2 May 2024 17:52:39 +0200 Subject: [PATCH 18/25] Fix assert --- tests/cohp/test_describe.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index c56e643e..69be85b8 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -371,10 +371,21 @@ def test_warnings(self): dos_comparison=True, bva_comp=False, ) - assert "Consider using DOSCAR.LSO.lobster" in str(w[0].message) - assert "Minimum energy range requested" in str(w[1].message) - assert "Maximum energy range requested" in str(w[2].message) - assert "Input DOS files have very few points" in str(w[3].message) + print(w[2].message) + print(w[3].message) + assert (str(w[0].message) == "Consider using DOSCAR.LSO.lobster, " + "as non LSO DOS from LOBSTER can have negative DOS values") + assert (str(w[1].message) == "Minimum energy range requested " + "for DOS comparisons is not available in VASP or" + " LOBSTER calculation. Thus, setting min_e to -5 eV") + assert (str(w[2].message) == "Maximum energy range requested " + "for DOS comparisons is not available in VASP or" + " LOBSTER calculation. Thus, setting max_e to 0 eV") + assert (str(w[3].message) == "Input DOS files have very " + "few points in the energy interval " + "and thus comparisons will not be reliable. Please rerun " + "the calculations with higher number of DOS points. Set NEDOS and COHPSteps" + " tags to >= 2000 in VASP and LOBSTER calculations, respectively.") calc_des = Description.get_calc_quality_description(calc_quality_warnings) @@ -419,8 +430,9 @@ def test_warnings(self): potcar_symbols=["Be_sv", "Te"], bva_comp=True, ) - - assert "Consider rerunning the calc with the minimum basis" in str(w3[0].message) == True + assert (str(w3[0].message) == "Consider rerunning the calc with the minimum basis as well. " + "Choosing is larger basis set is recommended if you see a significant " + "improvement of the charge spilling and material has non-zero band gap.") calc_des3 = Description.get_calc_quality_description(calc_quality_warnings3) From aab490db9b97be9bbf5719878873e62f5299bec9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 15:53:17 +0000 Subject: [PATCH 19/25] pre-commit auto-fixes --- tests/cohp/test_describe.py | 42 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index 69be85b8..7d62db9a 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -373,19 +373,27 @@ def test_warnings(self): ) print(w[2].message) print(w[3].message) - assert (str(w[0].message) == "Consider using DOSCAR.LSO.lobster, " - "as non LSO DOS from LOBSTER can have negative DOS values") - assert (str(w[1].message) == "Minimum energy range requested " - "for DOS comparisons is not available in VASP or" - " LOBSTER calculation. Thus, setting min_e to -5 eV") - assert (str(w[2].message) == "Maximum energy range requested " - "for DOS comparisons is not available in VASP or" - " LOBSTER calculation. Thus, setting max_e to 0 eV") - assert (str(w[3].message) == "Input DOS files have very " - "few points in the energy interval " - "and thus comparisons will not be reliable. Please rerun " - "the calculations with higher number of DOS points. Set NEDOS and COHPSteps" - " tags to >= 2000 in VASP and LOBSTER calculations, respectively.") + assert ( + str(w[0].message) == "Consider using DOSCAR.LSO.lobster, " + "as non LSO DOS from LOBSTER can have negative DOS values" + ) + assert ( + str(w[1].message) == "Minimum energy range requested " + "for DOS comparisons is not available in VASP or" + " LOBSTER calculation. Thus, setting min_e to -5 eV" + ) + assert ( + str(w[2].message) == "Maximum energy range requested " + "for DOS comparisons is not available in VASP or" + " LOBSTER calculation. Thus, setting max_e to 0 eV" + ) + assert ( + str(w[3].message) == "Input DOS files have very " + "few points in the energy interval " + "and thus comparisons will not be reliable. Please rerun " + "the calculations with higher number of DOS points. Set NEDOS and COHPSteps" + " tags to >= 2000 in VASP and LOBSTER calculations, respectively." + ) calc_des = Description.get_calc_quality_description(calc_quality_warnings) @@ -430,9 +438,11 @@ def test_warnings(self): potcar_symbols=["Be_sv", "Te"], bva_comp=True, ) - assert (str(w3[0].message) == "Consider rerunning the calc with the minimum basis as well. " - "Choosing is larger basis set is recommended if you see a significant " - "improvement of the charge spilling and material has non-zero band gap.") + assert ( + str(w3[0].message) == "Consider rerunning the calc with the minimum basis as well. " + "Choosing is larger basis set is recommended if you see a significant " + "improvement of the charge spilling and material has non-zero band gap." + ) calc_des3 = Description.get_calc_quality_description(calc_quality_warnings3) From 715b21248b77a2740bc25903ab6f78deddd61f8a Mon Sep 17 00:00:00 2001 From: JaGeo Date: Thu, 2 May 2024 17:56:31 +0200 Subject: [PATCH 20/25] removeprint --- tests/cohp/test_describe.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index 69be85b8..db766190 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -371,8 +371,7 @@ def test_warnings(self): dos_comparison=True, bva_comp=False, ) - print(w[2].message) - print(w[3].message) + assert (str(w[0].message) == "Consider using DOSCAR.LSO.lobster, " "as non LSO DOS from LOBSTER can have negative DOS values") assert (str(w[1].message) == "Minimum energy range requested " From 5cc7533a561157df818a3ac7f819046d1a07001e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 16:32:47 +0000 Subject: [PATCH 21/25] pre-commit auto-fixes --- tests/cohp/test_describe.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index aa749f4b..166c9b98 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -371,27 +371,27 @@ def test_warnings(self): dos_comparison=True, bva_comp=False, ) - messages=[] + messages = [] for warning in w: messages.append(str(warning.message)) - count0=0 - count1=0 - count2=0 - count3=0 + count0 = 0 + count1 = 0 + count2 = 0 + count3 = 0 for msg in messages: if "Consider using DOSCAR.LSO.lobster" in msg: - count0+=1 + count0 += 1 if "Minimum energy range requested" in msg: - count1+=1 + count1 += 1 if "Maximum energy range requested" in msg: - count2+=1 + count2 += 1 if "Input DOS files have very few points" in msg: count3 += 1 - assert count0 ==1 - assert count1 ==1 - assert count2 ==1 - assert count3 ==1 + assert count0 == 1 + assert count1 == 1 + assert count2 == 1 + assert count3 == 1 calc_des = Description.get_calc_quality_description(calc_quality_warnings) @@ -436,7 +436,10 @@ def test_warnings(self): potcar_symbols=["Be_sv", "Te"], bva_comp=True, ) - assert ("Consider rerunning the calc with the minimum basis as well. Choosing is larger basis set is recommended if you see a significant improvement of the charge spilling and material has non-zero band gap." == str(w3[0].message)) + assert ( + str(w3[0].message) + == "Consider rerunning the calc with the minimum basis as well. Choosing is larger basis set is recommended if you see a significant improvement of the charge spilling and material has non-zero band gap." + ) calc_des3 = Description.get_calc_quality_description(calc_quality_warnings3) From eb14e40aee162b165bc774936fa6b96fc498a855 Mon Sep 17 00:00:00 2001 From: JaGeo Date: Thu, 2 May 2024 18:38:25 +0200 Subject: [PATCH 22/25] Update tests --- tests/cohp/test_describe.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index aa749f4b..5ac44b4b 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -436,7 +436,9 @@ def test_warnings(self): potcar_symbols=["Be_sv", "Te"], bva_comp=True, ) - assert ("Consider rerunning the calc with the minimum basis as well. Choosing is larger basis set is recommended if you see a significant improvement of the charge spilling and material has non-zero band gap." == str(w3[0].message)) + assert ("Consider rerunning the calc with the minimum basis as well. " + "Choosing is larger basis set is recommended if you see a significant " + "improvement of the charge spilling and material has non-zero band gap." == str(w3[0].message)) calc_des3 = Description.get_calc_quality_description(calc_quality_warnings3) From f22d729d0fac1616cf33ba653c2e08d7a0f7f795 Mon Sep 17 00:00:00 2001 From: JaGeo Date: Thu, 2 May 2024 18:42:47 +0200 Subject: [PATCH 23/25] Update tests --- tests/cohp/test_describe.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index 4827a140..bcc8edad 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -436,17 +436,10 @@ def test_warnings(self): potcar_symbols=["Be_sv", "Te"], bva_comp=True, ) -<<<<<<< HEAD - assert ("Consider rerunning the calc with the minimum basis as well. " - "Choosing is larger basis set is recommended if you see a significant " - "improvement of the charge spilling and material has non-zero band gap." == str(w3[0].message)) -======= assert ( str(w3[0].message) == "Consider rerunning the calc with the minimum basis as well. Choosing is larger basis set is recommended if you see a significant improvement of the charge spilling and material has non-zero band gap." ) ->>>>>>> 5cc7533a561157df818a3ac7f819046d1a07001e - calc_des3 = Description.get_calc_quality_description(calc_quality_warnings3) assert calc_des3 == [ From 762da5af6ffc378e50d4e7fa98dcfa62cc6ed1d2 Mon Sep 17 00:00:00 2001 From: JaGeo Date: Thu, 2 May 2024 18:43:22 +0200 Subject: [PATCH 24/25] Update tests --- tests/cohp/test_describe.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index bcc8edad..b9e9d3aa 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -438,7 +438,9 @@ def test_warnings(self): ) assert ( str(w3[0].message) - == "Consider rerunning the calc with the minimum basis as well. Choosing is larger basis set is recommended if you see a significant improvement of the charge spilling and material has non-zero band gap." + == "Consider rerunning the calc with the minimum basis as well. " + "Choosing is larger basis set is recommended if you see a significant " + "improvement of the charge spilling and material has non-zero band gap." ) calc_des3 = Description.get_calc_quality_description(calc_quality_warnings3) From 2b627fea936f537d6c64baaac17fe4d1eb0a8266 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 16:43:49 +0000 Subject: [PATCH 25/25] pre-commit auto-fixes --- tests/cohp/test_describe.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index b9e9d3aa..6c35201e 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -437,10 +437,9 @@ def test_warnings(self): bva_comp=True, ) assert ( - str(w3[0].message) - == "Consider rerunning the calc with the minimum basis as well. " - "Choosing is larger basis set is recommended if you see a significant " - "improvement of the charge spilling and material has non-zero band gap." + str(w3[0].message) == "Consider rerunning the calc with the minimum basis as well. " + "Choosing is larger basis set is recommended if you see a significant " + "improvement of the charge spilling and material has non-zero band gap." ) calc_des3 = Description.get_calc_quality_description(calc_quality_warnings3)