Skip to content

Commit

Permalink
Migrated to pyproject.toml and ruff.
Browse files Browse the repository at this point in the history
  • Loading branch information
lauri-codes committed May 28, 2024
1 parent ab23272 commit 236f6e0
Show file tree
Hide file tree
Showing 35 changed files with 154 additions and 59 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: dependencies
- name: install
if: always()
run: |
cd ${GITHUB_WORKSPACE}/scripts && ./dependencies.sh
- name: lint
cd ${GITHUB_WORKSPACE}/scripts && ./install.sh
- name: format
if: always()
run: |
cd ${GITHUB_WORKSPACE}/scripts && ./lint.sh
- name: install
cd ${GITHUB_WORKSPACE}/scripts && ./format.sh
- name: lint
if: always()
run: |
cd ${GITHUB_WORKSPACE}/scripts && ./install.sh
cd ${GITHUB_WORKSPACE}/scripts && ./lint.sh
- name: test
if: always()
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Build status](https://github.com/SINGROUP/dscribe/actions/workflows/actions.yml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/SINGROUP/dscribe/badge.svg?branch=master)](https://coveralls.io/github/SINGROUP/dscribe?branch=master)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

DScribe is a Python package for transforming atomic structures into fixed-size
numerical fingerprints. These fingerprints are often called "descriptors" and
Expand Down
9 changes: 0 additions & 9 deletions devrequirements.txt

This file was deleted.

1 change: 1 addition & 0 deletions dscribe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

from dscribe.core.system import System
1 change: 1 addition & 0 deletions dscribe/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

from dscribe.core.system import System
from dscribe.core.lattice import Lattice
1 change: 1 addition & 0 deletions dscribe/core/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np


Expand Down
1 change: 1 addition & 0 deletions dscribe/core/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

from ase import Atoms
import ase.geometry
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

from dscribe.descriptors.acsf import ACSF
from dscribe.descriptors.mbtr import MBTR
from dscribe.descriptors.valleoganov import ValleOganov
Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/acsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np
from ase import Atoms

Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/coulombmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np
from ase import Atoms
import ase.geometry.cell
Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

from abc import ABC, abstractmethod

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/descriptorglobal.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np
import sparse as sp
from ase import Atoms
Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/descriptorlocal.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np
from ase import Atoms

Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/descriptormatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np
from numpy.random import RandomState

Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/ewaldsummatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import math

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/lmbtr.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import sys
import math

Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/mbtr.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import sys
import math
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/sinematrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np

from ase import Atoms
Expand Down
1 change: 1 addition & 0 deletions dscribe/descriptors/soap.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

from warnings import warn

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions dscribe/kernels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

from dscribe.kernels.averagekernel import AverageKernel
from dscribe.kernels.rematchkernel import REMatchKernel
1 change: 1 addition & 0 deletions dscribe/kernels/averagekernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np
from dscribe.kernels.localsimilaritykernel import LocalSimilarityKernel

Expand Down
1 change: 1 addition & 0 deletions dscribe/kernels/localsimilaritykernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

from abc import ABC, abstractmethod

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions dscribe/kernels/rematchkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np
from dscribe.kernels.localsimilaritykernel import LocalSimilarityKernel

Expand Down
1 change: 1 addition & 0 deletions dscribe/utils/dimensionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np


Expand Down
1 change: 1 addition & 0 deletions dscribe/utils/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np

import scipy.sparse
Expand Down
1 change: 1 addition & 0 deletions dscribe/utils/species.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import numpy as np
import ase.data

Expand Down
1 change: 1 addition & 0 deletions dscribe/utils/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

from ase import Atoms
from dscribe.core.system import System
import numpy as np
Expand Down
105 changes: 105 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"pybind11>=2.4"
]
build-backend = "setuptools.build_meta"

[project]
name = 'dscribe'
version = '2.1.1'
description = 'A Python package for creating feature transformations in applications of machine learning to materials science.'
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.8"
dependencies = [
"numpy",
"scipy",
"ase>=3.19.0",
"scikit-learn",
"joblib>=1.0.0",
"sparse",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
"License :: OSI Approved :: Apache Software License",
"Operating System :: MacOS",
"Operating System :: Unix",
"Programming Language :: C",
"Programming Language :: C++",
"Programming Language :: Python",
"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 :: Only",
]
keywords = ['descriptor', 'machine learning', 'atomistic structure', 'materials science']

[project.urls]
Documentation = 'https://singroup.github.io/dscribe/latest/'
Source = "https://singroup.github.io/dscribe"

[project.optional-dependencies]
dev = [
"coverage",
"ruff",
"coveralls",
"pymatgen",
"sphinx",
"sphinx_rtd_theme",
"sphinxcontrib-bibtex",
"pytest",
]

[tool.setuptools.packages.find]
include = ["dscribe*"]
exclude = ["tests*"]

[tool.ruff]
include = ["dscribe/*.py", "tests/*.py"]

# Same as Black
line-length = 88
indent-width = 4

[tool.ruff.lint]
select = [
"E", # pycodestyle
"W", # pycodestyle
"PL", # pylint
]
ignore = [
"E501", # Line too long ({width} > {limit} characters)
"E701", # Multiple statements on one line (colon)
"E731", # Do not assign a lambda expression, use a def
"E402", # Module level import not at top of file
"E741", # Ambiguous variable name
"W605", # Invalid escape sequence
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0913", # Too many arguments in function definition
"PLR0915", # Too many statements
"PLR2004", # Magic value used instead of constant
"PLW0603", # Using the global statement
"PLW2901", # redefined-loop-name
"PLR1714", # consider-using-in
"PLR5501", # else-if-used
]
fixable = ["ALL"]

[tool.ruff.format]
# indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
5 changes: 0 additions & 5 deletions scripts/dependencies.sh

This file was deleted.

5 changes: 5 additions & 0 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
cd ..
ruff format --check


6 changes: 5 additions & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Update pip and setuptools
pip install pip --upgrade
pip install setuptools --upgrade

# Make a source distribution
cd ..
python setup.py sdist
Expand All @@ -8,4 +12,4 @@ version=`python setup.py --version`
cd dist
tar xvzf dscribe-$version.tar.gz
cd dscribe-$version
pip install .
pip install .[dev]
3 changes: 2 additions & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
cd ..
black --check dscribe tests
ruff check

Loading

0 comments on commit 236f6e0

Please sign in to comment.