From cf99d874c0ea8cd8fe41e6d503a128b8019265ab Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Wed, 2 Oct 2024 11:21:23 +0800 Subject: [PATCH 01/17] replace HalfspaceIntersection import --- pymatgen/analysis/alloys/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymatgen/analysis/alloys/core.py b/pymatgen/analysis/alloys/core.py index 6be462b..d2d5891 100644 --- a/pymatgen/analysis/alloys/core.py +++ b/pymatgen/analysis/alloys/core.py @@ -25,7 +25,7 @@ from monty.json import MSONable from plotly.subplots import make_subplots from pymatgen.analysis.phase_diagram import PhaseDiagram -from scipy.spatial.qhull import HalfspaceIntersection +from scipy.spatial import HalfspaceIntersection from shapely.geometry import MultiPoint from typing import List, Tuple, Optional, Dict, Literal, Any, Set, Callable, Union from scipy.constants import c, h, elementary_charge From d7892d70b6582a0885c2261e6c362cd5f37ad10a Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 12:18:07 +0800 Subject: [PATCH 02/17] sort imports --- pymatgen/analysis/alloys/core.py | 20 +++++++++----------- pymatgen/analysis/alloys/tests/test_core.py | 5 ++--- setup.py | 4 ++-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/pymatgen/analysis/alloys/core.py b/pymatgen/analysis/alloys/core.py index d2d5891..40eb7a0 100644 --- a/pymatgen/analysis/alloys/core.py +++ b/pymatgen/analysis/alloys/core.py @@ -9,29 +9,29 @@ # TODO: A `FormulaAlloySystem` is defined consisting of `FormulaAlloyPair` and specifies # the full space accessible for a given composition. +import hashlib import warnings from dataclasses import dataclass, field +from itertools import chain, groupby +from pathlib import Path +from typing import Any, Callable, Dict, List, Literal, Optional, Set, Tuple, Union -import hashlib import networkx as nx import numpy as np import pandas as pd import plotly.express as px - import plotly.graph_objects as go -from monty.serialization import loadfn -from pathlib import Path -from itertools import groupby, chain from monty.json import MSONable +from monty.serialization import loadfn from plotly.subplots import make_subplots -from pymatgen.analysis.phase_diagram import PhaseDiagram +from scipy.constants import c, elementary_charge, h from scipy.spatial import HalfspaceIntersection from shapely.geometry import MultiPoint -from typing import List, Tuple, Optional, Dict, Literal, Any, Set, Callable, Union -from scipy.constants import c, h, elementary_charge -from pymatgen.core.composition import Species, Composition +from pymatgen.analysis.alloys.rgb import rgb +from pymatgen.analysis.phase_diagram import PhaseDiagram from pymatgen.analysis.structure_matcher import ElementComparator +from pymatgen.core.composition import Composition, Species from pymatgen.core.structure import Structure from pymatgen.transformations.standard_transformations import ( AutoOxiStateDecorationTransformation, @@ -39,8 +39,6 @@ ) from pymatgen.util.string import unicodeify -from pymatgen.analysis.alloys.rgb import rgb - # structure matching parameters LTOL: float = 0.2 STOL: float = 0.3 diff --git a/pymatgen/analysis/alloys/tests/test_core.py b/pymatgen/analysis/alloys/tests/test_core.py index 5c69966..67b4e0c 100644 --- a/pymatgen/analysis/alloys/tests/test_core.py +++ b/pymatgen/analysis/alloys/tests/test_core.py @@ -1,12 +1,11 @@ from pathlib import Path from typing import Dict -from pytest import raises from monty.serialization import loadfn -from pymatgen.core import Structure, Composition +from pytest import raises from pymatgen.analysis.alloys.core import AlloyPair - +from pymatgen.core import Composition, Structure mp_661: Structure = loadfn(Path(__file__).parent / "AlN_mp-661.json") mp_661_without_oxi_state = mp_661.copy() diff --git a/setup.py b/setup.py index 12b098a..d775e12 100644 --- a/setup.py +++ b/setup.py @@ -4,10 +4,10 @@ # and distributed under the terms of the Modified BSD License. # pymatgen-analysis-alloys is Copyright (c) Rachel Woods-Robinson, Matthew Horton -from setuptools import setup, find_namespace_packages - import os +from setuptools import find_namespace_packages, setup + SETUP_PTH = os.path.dirname(os.path.abspath(__file__)) with open(os.path.join(SETUP_PTH, "README.md")) as readme: From b71e3fbd1684f9144d0d35413cba16f985707a38 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 12:18:42 +0800 Subject: [PATCH 03/17] tweak pytest usage --- pymatgen/analysis/alloys/tests/test_core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pymatgen/analysis/alloys/tests/test_core.py b/pymatgen/analysis/alloys/tests/test_core.py index 67b4e0c..fa412f1 100644 --- a/pymatgen/analysis/alloys/tests/test_core.py +++ b/pymatgen/analysis/alloys/tests/test_core.py @@ -1,8 +1,8 @@ from pathlib import Path from typing import Dict +import pytest from monty.serialization import loadfn -from pytest import raises from pymatgen.analysis.alloys.core import AlloyPair from pymatgen.core import Composition, Structure @@ -161,7 +161,7 @@ def test_get_x(): assert pair.get_x(c1) == 0.5 assert pair.get_x(c2) == 0.5 assert pair.get_x(c3) == 2/3 - with raises(ValueError): + with pytest.raises(ValueError): pair.get_x(c4) - with raises(ValueError): + with pytest.raises(ValueError): pair.get_x(c5) From 6a61fa5ea3df8892dbba252e8aa89358e3e95938 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 12:20:18 +0800 Subject: [PATCH 04/17] relocate comment --- pymatgen/analysis/alloys/core.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pymatgen/analysis/alloys/core.py b/pymatgen/analysis/alloys/core.py index 40eb7a0..090f18d 100644 --- a/pymatgen/analysis/alloys/core.py +++ b/pymatgen/analysis/alloys/core.py @@ -5,10 +5,11 @@ A `FormulaAlloyPair` class contains `AlloyPairs` which have formation energies known to estimate which AlloyPair is stable for a given composition. + +TODO: A `FormulaAlloySystem` is defined consisting of `FormulaAlloyPair` and +specifies the full space accessible for a given composition. """ -# TODO: A `FormulaAlloySystem` is defined consisting of `FormulaAlloyPair` and specifies -# the full space accessible for a given composition. import hashlib import warnings from dataclasses import dataclass, field From bc95615d39a8c706ccf67a24f9b39f365cccb81a Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 12:40:04 +0800 Subject: [PATCH 05/17] remove *.in as MANIFEST.in is included by default --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 90bde4b..be98092 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include *.rst *.in requirements.txt +include *.rst requirements.txt recursive-include pymatgen *.py prune */tests prune */*/tests From 659d24db2ac62d59a159d38fb17c2990943f93c6 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 12:40:30 +0800 Subject: [PATCH 06/17] remove *.rst as there's no rst file --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index be98092..23da1e2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include *.rst requirements.txt +include requirements.txt recursive-include pymatgen *.py prune */tests prune */*/tests From d818d07a0b1db54e2068cae57906339d6bf08920 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 12:41:34 +0800 Subject: [PATCH 07/17] remove *.py as py is included by default --- MANIFEST.in | 1 - 1 file changed, 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 23da1e2..5f6fab6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,4 @@ include requirements.txt -recursive-include pymatgen *.py prune */tests prune */*/tests prune */*/*/tests From cbf3fdefd5ed07f89e282c7e8c3ff97aebd3a512 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 12:44:16 +0800 Subject: [PATCH 08/17] avoid hard coding nest level --- MANIFEST.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 5f6fab6..098bb23 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,3 @@ include requirements.txt -prune */tests -prune */*/tests -prune */*/*/tests +global-exclude */tests/* +prune */tests/ From 24ab9b94b81ec62f297c99af390cadc46df2ee7d Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 12:51:20 +0800 Subject: [PATCH 09/17] bump supported python versions to python 3.12 --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.py b/setup.py index d775e12..a78f1a0 100644 --- a/setup.py +++ b/setup.py @@ -35,6 +35,10 @@ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", From 76a9e42a03e70a8df6f255f2654832452095fd1e Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 12:53:12 +0800 Subject: [PATCH 10/17] NEED CONFIRM: update install dependencies --- setup.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a78f1a0..a67793c 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,16 @@ name="pymatgen-analysis-alloys", packages=find_namespace_packages(include=["pymatgen.analysis.*"]), version="0.0.6", - install_requires=["pymatgen>=2022.0.3", "shapely>=1.8.2"], + install_requires=[ + "monty", + "networkx", + "numpy", + "pandas", + "plotly", + "pymatgen>=2022.0.3", + "scipy>=1.8.0", + "shapely>=1.8.2", + ], extras_require={}, package_data={ "pymatgen.analysis.alloys": ["*.yaml", "*.json", "*.csv"], From 9636ee7fcb02a721aa0aee03e6a4b4d7bbbc5c20 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 15:40:11 +0800 Subject: [PATCH 11/17] bump setuptools as <58 has known bug with package data handling --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 885df90..feb57d4 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,7 @@ "shapely>=1.8.2", ], extras_require={}, + setup_requires=["setuptools>=64"], package_data={ "pymatgen.analysis.alloys": ["*.yaml", "*.json", "*.csv"], }, From a697cc4e7b762b5168927c26a423e448ed84a169 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 15:46:06 +0800 Subject: [PATCH 12/17] bump github action ver, drop unused env --- .github/workflows/linting.yml | 4 ++-- .github/workflows/testing.yml | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index c782de1..0fbd186 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -11,11 +11,11 @@ jobs: python-version: [3.8] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 6737d4d..2a0ee10 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -13,14 +13,10 @@ jobs: runs-on: ${{ matrix.os }} - env: - PMG_MAPI_KEY: ${{ secrets.PMG_MAPI_KEY }} - MPLBACKEND: "Agg" - steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies From f3e3ef65451a5dcf9699d612cdf8c537e8fa5748 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 8 Oct 2024 15:49:23 +0800 Subject: [PATCH 13/17] space out a bit for readability --- .github/workflows/linting.yml | 7 +++++++ .github/workflows/testing.yml | 3 +++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 0fbd186..e1fe854 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -14,29 +14,36 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements-ci.txt --quiet + - name: mypy run: | mypy --namespace-packages --explicit-package-bases pymatgen + - name: black run: | black --version black --check --diff --color pymatgen + - name: flake8 run: | flake8 --count --show-source --statistics pymatgen # exit-zero treats all errors as warnings. flake8 --count --exit-zero --max-complexity=20 --statistics pymatgen + - name: pydocstyle run: | pydocstyle --count pymatgen + - name: pylint run: | pylint pymatgen \ No newline at end of file diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2a0ee10..688abc6 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -15,15 +15,18 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install --upgrade pip pip install --quiet -r requirements.txt -r requirements-ci.txt pip install -e . + - name: pytest run: | pytest --cov=pymatgen.analysis.diffusion --durations=30 pymatgen From c2be4571eedd1fdbc29008f41eb1b5f651a82804 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Wed, 9 Oct 2024 10:15:32 +0800 Subject: [PATCH 14/17] revert changes in manifest.in --- MANIFEST.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 098bb23..90bde4b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,5 @@ -include requirements.txt -global-exclude */tests/* -prune */tests/ +include *.rst *.in requirements.txt +recursive-include pymatgen *.py +prune */tests +prune */*/tests +prune */*/*/tests From 5c6b924a96ff4a96f8b883e3beb15f436a88f657 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Wed, 9 Oct 2024 10:15:44 +0800 Subject: [PATCH 15/17] revert changes in Github action --- .github/workflows/linting.yml | 11 ++--------- .github/workflows/testing.yml | 11 ++++++----- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index e1fe854..c782de1 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -11,39 +11,32 @@ jobs: python-version: [3.8] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements-ci.txt --quiet - - name: mypy run: | mypy --namespace-packages --explicit-package-bases pymatgen - - name: black run: | black --version black --check --diff --color pymatgen - - name: flake8 run: | flake8 --count --show-source --statistics pymatgen # exit-zero treats all errors as warnings. flake8 --count --exit-zero --max-complexity=20 --statistics pymatgen - - name: pydocstyle run: | pydocstyle --count pymatgen - - name: pylint run: | pylint pymatgen \ No newline at end of file diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 688abc6..6737d4d 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -13,20 +13,21 @@ jobs: runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 + env: + PMG_MAPI_KEY: ${{ secrets.PMG_MAPI_KEY }} + MPLBACKEND: "Agg" + steps: + - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies run: | python -m pip install --upgrade pip pip install --quiet -r requirements.txt -r requirements-ci.txt pip install -e . - - name: pytest run: | pytest --cov=pymatgen.analysis.diffusion --durations=30 pymatgen From 4ab31d9215cdcd9f7c4183c60bd0ae6e8c3bca12 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Wed, 9 Oct 2024 10:16:36 +0800 Subject: [PATCH 16/17] revert addition of supported python version in setup.py --- setup.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/setup.py b/setup.py index feb57d4..bb747b4 100644 --- a/setup.py +++ b/setup.py @@ -45,10 +45,6 @@ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", From c783cd1ccfc1c10e34f2e5eec2e6312c6b75dcea Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Wed, 9 Oct 2024 10:18:01 +0800 Subject: [PATCH 17/17] revert reposition of comment --- pymatgen/analysis/alloys/core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pymatgen/analysis/alloys/core.py b/pymatgen/analysis/alloys/core.py index bb89513..f759055 100644 --- a/pymatgen/analysis/alloys/core.py +++ b/pymatgen/analysis/alloys/core.py @@ -5,11 +5,11 @@ A `FormulaAlloyPair` class contains `AlloyPairs` which have formation energies known to estimate which AlloyPair is stable for a given composition. - -TODO: A `FormulaAlloySystem` is defined consisting of `FormulaAlloyPair` and -specifies the full space accessible for a given composition. """ +# TODO: A `FormulaAlloySystem` is defined consisting of `FormulaAlloyPair` and specifies +# the full space accessible for a given composition. + import hashlib import warnings from dataclasses import dataclass, field