diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2410563b6..caf4a59c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python-version: ["3.7", "3.8", "3.12"] + python-version: ["3.8", "3.12"] steps: - uses: actions/checkout@v4 diff --git a/README.md b/README.md index 6f9246b1c..3ca2355c6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Installation -DP-GEN only supports Python 3.7 and above. You can [setup a conda/pip environment](https://docs.deepmodeling.com/faq/conda.html), and then use one of the following methods to install DP-GEN: +dpdata only supports Python 3.8 and above. You can [setup a conda/pip environment](https://docs.deepmodeling.com/faq/conda.html), and then use one of the following methods to install dpdata: - Install via pip: `pip install dpdata` - Install via conda: `conda install -c conda-forge dpdata` diff --git a/docs/make_format.py b/docs/make_format.py index 2b3c03c67..e9c1f60d3 100644 --- a/docs/make_format.py +++ b/docs/make_format.py @@ -2,14 +2,9 @@ import csv import os -import sys from collections import defaultdict from inspect import Parameter, Signature, cleandoc, signature - -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal +from typing import Literal from numpydoc.docscrape import Parameter as numpydoc_Parameter from numpydoc.docscrape_sphinx import SphinxDocString diff --git a/dpdata/stat.py b/dpdata/stat.py index ed74c258d..bda66a2ee 100644 --- a/dpdata/stat.py +++ b/dpdata/stat.py @@ -116,7 +116,7 @@ class Errors(ErrorsBase): SYSTEM_TYPE = LabeledSystem @property - @lru_cache() + @lru_cache def e_errors(self) -> np.ndarray: """Energy errors.""" assert isinstance(self.system_1, self.SYSTEM_TYPE) @@ -124,7 +124,7 @@ def e_errors(self) -> np.ndarray: return self.system_1["energies"] - self.system_2["energies"] @property - @lru_cache() + @lru_cache def f_errors(self) -> np.ndarray: """Force errors.""" assert isinstance(self.system_1, self.SYSTEM_TYPE) @@ -153,7 +153,7 @@ class MultiErrors(ErrorsBase): SYSTEM_TYPE = MultiSystems @property - @lru_cache() + @lru_cache def e_errors(self) -> np.ndarray: """Energy errors.""" assert isinstance(self.system_1, self.SYSTEM_TYPE) @@ -166,7 +166,7 @@ def e_errors(self) -> np.ndarray: return np.concatenate(errors) @property - @lru_cache() + @lru_cache def f_errors(self) -> np.ndarray: """Force errors.""" assert isinstance(self.system_1, self.SYSTEM_TYPE) diff --git a/dpdata/system.py b/dpdata/system.py index 001726020..5edc8e44b 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -5,21 +5,16 @@ import hashlib import numbers import os -import sys import warnings from copy import deepcopy from typing import ( TYPE_CHECKING, Any, Iterable, + Literal, overload, ) -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal - import numpy as np import dpdata diff --git a/dpdata/unit.py b/dpdata/unit.py index 09981b969..e8a86fe5a 100644 --- a/dpdata/unit.py +++ b/dpdata/unit.py @@ -4,11 +4,49 @@ from scipy import constants # noqa: TID253 -AVOGADRO = constants.Avogadro # Avagadro constant -ELE_CHG = constants.elementary_charge # Elementary Charge, in C -BOHR = constants.value("atomic unit of length") # Bohr, in m -HARTREE = constants.value("atomic unit of energy") # Hartree, in Jole -RYDBERG = constants.Rydberg * constants.h * constants.c # Rydberg, in Jole +physical_constants = {} +# use constants up to 2018 +physical_constants.update(constants._codata._physical_constants_2002) +physical_constants.update(constants._codata._physical_constants_2006) +physical_constants.update(constants._codata._physical_constants_2010) +physical_constants.update(constants._codata._physical_constants_2014) +physical_constants.update(constants._codata._physical_constants_2018) + + +# copied from scipy +def scipy_constant_value(key: str) -> float: + """Value in physical_constants indexed by key. + + Parameters + ---------- + key : Python string + Key in dictionary `physical_constants` + + Returns + ------- + value : float + Value in `physical_constants` corresponding to `key` + + Examples + -------- + >>> from scipy import constants + >>> constants.value('elementary charge') + 1.602176634e-19 + + """ + constants._codata._check_obsolete(key) + return physical_constants[key][0] + + +AVOGADRO = scipy_constant_value("Avogadro constant") # Avagadro constant +ELE_CHG = scipy_constant_value("elementary charge") # Elementary Charge, in C +BOHR = scipy_constant_value("atomic unit of length") # Bohr, in m +HARTREE = scipy_constant_value("atomic unit of energy") # Hartree, in Jole +RYDBERG = ( + scipy_constant_value("Rydberg constant") + * scipy_constant_value("Planck constant") + * scipy_constant_value("speed of light in vacuum") +) # Rydberg, in Jole # energy conversions econvs = { diff --git a/dpdata/utils.py b/dpdata/utils.py index 8942bd54d..58a908cc7 100644 --- a/dpdata/utils.py +++ b/dpdata/utils.py @@ -2,14 +2,9 @@ import io import os -import sys from contextlib import contextmanager -from typing import TYPE_CHECKING, Generator, overload +from typing import TYPE_CHECKING, Generator, Literal, overload -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal import numpy as np from dpdata.periodic_table import Element diff --git a/pyproject.toml b/pyproject.toml index 514025e71..65cf6f21b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ authors = [ ] license = {file = "LICENSE"} classifiers = [ - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -28,7 +27,7 @@ dependencies = [ 'importlib_metadata>=1.4; python_version < "3.8"', 'typing_extensions; python_version < "3.8"', ] -requires-python = ">=3.7" +requires-python = ">=3.8" readme = "README.md" keywords = ["lammps", "vasp", "deepmd-kit"] @@ -46,7 +45,6 @@ test = [ ase = ['ase'] amber = [ 'parmed; python_version >= "3.8"', - 'parmed<4; python_version < "3.8"', ] pymatgen = ['pymatgen'] docs = [