From 2d27e36d902763dbe295eccf89c9afa8eaadb4d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:38:53 -0400 Subject: [PATCH 1/5] Bump actions/checkout from 2 to 4 (#631) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 4.
Release notes

Sourced from actions/checkout's releases.

v4.0.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v4.0.0

v3.6.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3.5.3...v3.6.0

v3.5.3

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v3.5.3

v3.5.2

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v3.5.1...v3.5.2

v3.5.1

What's Changed

New Contributors

... (truncated)

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=2&new-version=4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 2 +- .github/workflows/test_import.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e88b72b..32e5fde6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: python-version: ["3.7", "3.8", "3.12"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # set up conda - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 diff --git a/.github/workflows/test_import.yml b/.github/workflows/test_import.yml index b04d05cd..9f1f7d8e 100644 --- a/.github/workflows/test_import.yml +++ b/.github/workflows/test_import.yml @@ -8,7 +8,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/setup-python@v2 with: python-version: '3.9' From 38691462dbbca535115804ad413fe380a2b483d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:43:07 -0400 Subject: [PATCH 2/5] Bump actions/setup-python from 2 to 5 (#630) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2 to 5.
Release notes

Sourced from actions/setup-python's releases.

v5.0.0

What's Changed

In scope of this release, we update node version runtime from node16 to node20 (actions/setup-python#772). Besides, we update dependencies to the latest versions.

Full Changelog: https://github.com/actions/setup-python/compare/v4.8.0...v5.0.0

v4.8.0

What's Changed

In scope of this release we added support for GraalPy (actions/setup-python#694). You can use this snippet to set up GraalPy:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
  with:
    python-version: 'graalpy-22.3'
- run: python my_script.py

Besides, the release contains such changes as:

New Contributors

Full Changelog: https://github.com/actions/setup-python/compare/v4...v4.8.0

v4.7.1

What's Changed

Full Changelog: https://github.com/actions/setup-python/compare/v4...v4.7.1

v4.7.0

In scope of this release, the support for reading python version from pyproject.toml was added (actions/setup-python#669).

      - name: Setup Python
        uses: actions/setup-python@v4
</tr></table>

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/setup-python&package-manager=github_actions&previous-version=2&new-version=5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 2 +- .github/workflows/test_import.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 32e5fde6..e4d9a91f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 # set up conda - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} # install rdkit and openbabel diff --git a/.github/workflows/test_import.yml b/.github/workflows/test_import.yml index 9f1f7d8e..6ab0dbe2 100644 --- a/.github/workflows/test_import.yml +++ b/.github/workflows/test_import.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: '3.9' architecture: 'x64' From 17fe0aa1381937144224995ce51575acf8c8ff30 Mon Sep 17 00:00:00 2001 From: m0sey <61280022+MoseyQAQ@users.noreply.github.com> Date: Fri, 5 Apr 2024 22:34:05 +0800 Subject: [PATCH 3/5] PyMatgenStructureFormat with from_system method (#626) Now the PyMatgenStructureFormat doesn't support the from_system method. This PR adds this method, enabling users to convert the pymatgen.core.Structure to the dpdata format, which is convenient when you use pymatgen.transformations to build the atomic model. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- dpdata/plugins/pymatgen.py | 18 ++++++++++++++++++ dpdata/pymatgen/structure.py | 24 ++++++++++++++++++++++++ tests/test_from_pymatgen.py | 30 ++++++++++++++++++++++++++++++ tests/test_to_pymatgen.py | 4 ++-- 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 dpdata/pymatgen/structure.py create mode 100644 tests/test_from_pymatgen.py diff --git a/dpdata/plugins/pymatgen.py b/dpdata/plugins/pymatgen.py index 82b64e71..e7e527ff 100644 --- a/dpdata/plugins/pymatgen.py +++ b/dpdata/plugins/pymatgen.py @@ -1,11 +1,29 @@ import numpy as np import dpdata.pymatgen.molecule +import dpdata.pymatgen.structure from dpdata.format import Format @Format.register("pymatgen/structure") class PyMatgenStructureFormat(Format): + def from_system(self, structure, **kwargs) -> dict: + """Convert pymatgen.core.Structure to System. + + Parameters + ---------- + structure : pymatgen.core.Structure + a Pymatgen Structure, containing a structure + **kwargs : dict + other parameters + + Returns + ------- + dict + data dict + """ + return dpdata.pymatgen.structure.from_system_data(structure) + def to_system(self, data, **kwargs): """Convert System to Pymatgen Structure obj.""" structures = [] diff --git a/dpdata/pymatgen/structure.py b/dpdata/pymatgen/structure.py new file mode 100644 index 00000000..b6c148da --- /dev/null +++ b/dpdata/pymatgen/structure.py @@ -0,0 +1,24 @@ +import numpy as np + +try: + from pymatgen.core import Structure # noqa: F401 +except ImportError: + pass + + +def from_system_data(structure) -> dict: + symbols = [site.species_string for site in structure] + atom_names = list(structure.symbol_set) + atom_numbs = [symbols.count(symbol) for symbol in atom_names] + atom_types = np.array([atom_names.index(symbol) for symbol in symbols]).astype(int) + coords = structure.cart_coords + cells = structure.lattice.matrix + + info_dict = { + "atom_names": atom_names, + "atom_numbs": atom_numbs, + "atom_types": atom_types, + "coords": np.array([coords]), + "cells": np.array([cells]), + } + return info_dict diff --git a/tests/test_from_pymatgen.py b/tests/test_from_pymatgen.py new file mode 100644 index 00000000..d3ddbe3e --- /dev/null +++ b/tests/test_from_pymatgen.py @@ -0,0 +1,30 @@ +import os +import unittest + +from comp_sys import CompSys +from context import dpdata + +try: + from pymatgen.core import Structure # noqa: F401 + + exist_module = True +except Exception: + exist_module = False + + +@unittest.skipIf(not exist_module, "skip pymatgen") +class TestFormPytmatgen(unittest.TestCase, CompSys): + def setUp(self): + structure = Structure.from_file(os.path.join("poscars", "POSCAR.P42nmc")) + self.system_1 = dpdata.System(structure, fmt="pymatgen/structure") + self.system_2 = dpdata.System( + os.path.join("poscars", "POSCAR.P42nmc"), fmt="poscar" + ) + self.places = 6 + self.e_places = 6 + self.f_places = 6 + self.v_places = 6 + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_to_pymatgen.py b/tests/test_to_pymatgen.py index d5815396..b55443d4 100644 --- a/tests/test_to_pymatgen.py +++ b/tests/test_to_pymatgen.py @@ -5,7 +5,7 @@ from context import dpdata try: - from pymatgen import Structure # noqa: F401 + from pymatgen.core import Structure # noqa: F401 exist_module = True except Exception: @@ -19,7 +19,7 @@ def setUp(self): system_1.from_lammps_lmp( os.path.join("poscars", "conf.lmp"), type_map=["O", "H"] ) - system_1.to_pymatgen_structure()[0].to("poscar", "tmp.POSCAR") + system_1.to_pymatgen_structure()[0].to(filename="tmp.POSCAR", fmt="poscar") self.system_1 = system_1 self.system_2 = dpdata.System("tmp.POSCAR") self.places = 6 From a5c0252eeb008659428e682a1b891da5800eedee Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 08:31:00 +0800 Subject: [PATCH 4/5] [pre-commit.ci] pre-commit autoupdate (#634) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v4.6.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.5.0...v4.6.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a7a2afa8..c199c7ad 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: # there are many log files in tests # TODO: seperate py files and log files From 4bf2f57ba43d92a3ccce41e815eff28c7a98250f Mon Sep 17 00:00:00 2001 From: "njzjz-bot[bot]" <48687836+njzjz-bot@users.noreply.github.com> Date: Fri, 12 Apr 2024 21:34:53 -0400 Subject: [PATCH 5/5] feat(build): Add Git archives version files When downloading the source code of a branch or a release from GitHub or the mirror, there is no Git version information, making setuptools-scm unable to read the version. The alternative way is to add a git archive file supported by setuptools-scm. See: * https://setuptools-scm.readthedocs.io/en/latest/usage/#git-archives (available in setuptools-scm 7.0.0) * https://git-scm.com/docs/git-archive#Documentation/git-archive.txt-export-subst * https://docs.github.com/en/repositories/working-with-files/using-files/downloading-source-code-archives Generated by the task: https://github.com/njzjz-bot/njzjz-bot/issues/4. --- .git_archival.txt | 4 ++++ .gitattributes | 1 + pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .git_archival.txt create mode 100644 .gitattributes diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 00000000..8fb235d7 --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1,4 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ +ref-names: $Format:%D$ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..00a7b00c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.git_archival.txt export-subst diff --git a/pyproject.toml b/pyproject.toml index 8fe408eb..3f09801a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61", "setuptools_scm[toml]>=6.2"] +requires = ["setuptools>=61", "setuptools_scm[toml]>=7"] build-backend = "setuptools.build_meta" [project]