Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/numpy-2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen authored Sep 12, 2024
2 parents b47b393 + 025cc2d commit 8114457
Show file tree
Hide file tree
Showing 22 changed files with 911 additions and 220 deletions.
3 changes: 2 additions & 1 deletion .ci_support/environment-lammps.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
channels:
- conda-forge
dependencies:
- lammps =2024.02.07
- lammps =2024.06.27=*openmpi*
- openmpi =4.1.6
14 changes: 7 additions & 7 deletions .ci_support/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ dependencies:
- ase =3.23.0
- coverage
- dscribe =2.1.1
- matplotlib-base =3.9.1
- matplotlib-base =3.9.2
- nglview =3.1.2
- notebook
- numpy =2.1.1
- phonopy =2.26.6
- plotly =5.22.0
- pymatgen =2024.6.10
- pyscal3 =3.2.6
- pyxtal =0.6.7
- scikit-learn =1.5.1
- scipy =1.14.0
- plotly =5.24.0
- pymatgen =2024.9.10
- pyscal3 =3.2.7
- pyxtal =1.0.3
- scikit-learn =1.5.2
- scipy =1.14.1
- spglib =2.5.0
- sqsgenerator =0.3
2 changes: 1 addition & 1 deletion .ci_support/environment_mini.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ dependencies:
- ase =3.23.0
- coverage
- numpy =2.1.1
- scipy =1.14.0
- scipy =1.14.1
15 changes: 6 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@ jobs:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Conda config
run: echo -e "channels:\n - conda-forge\n" > .condarc
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: "3.12"
mamba-version: "*"
channels: conda-forge
miniforge-variant: Mambaforge
channel-priority: strict
auto-update-conda: true
miniforge-version: latest
condarc-file: .condarc
environment-file: .ci_support/environment.yml
- name: Convert dependencies
run: |
cp .ci_support/environment-old.yml environment.yml
python .ci_support/release.py; cat pyproject.toml
- name: Build
shell: bash -l {0}
run: |
cp .ci_support/environment-old.yml environment.yml
python .ci_support/release.py; cat pyproject.toml
pip install versioneer[toml]==0.29
python setup.py sdist bdist_wheel
- name: Publish distribution 📦 to PyPI
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/mini.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Conda config
run: echo -e "channels:\n - conda-forge\n" > .condarc
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.12'
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
activate-environment: my-env
miniforge-version: latest
condarc-file: .condarc
environment-file: .ci_support/environment_mini.yml
use-mamba: true
- name: Test
shell: bash -l {0}
timeout-minutes: 30
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/pypicheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Conda config
run: echo -e "channels:\n - conda-forge\n" > .condarc
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.12'
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
activate-environment: my-env
miniforge-version: latest
condarc-file: .condarc
environment-file: .ci_support/environment.yml
use-mamba: true
- name: Pip check
shell: bash -l {0}
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ jobs:
- name: Merge conda environment
if: matrix.operating-system != 'windows-latest'
run: tail --lines=+4 .ci_support/environment-lammps.yml >> .ci_support/environment.yml
- name: Conda config
shell: bash -l {0}
run: echo -e "channels:\n - conda-forge\n" > .condarc
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
activate-environment: my-env
miniforge-version: latest
condarc-file: .condarc
environment-file: .ci_support/environment.yml
use-mamba: true
- name: Test
shell: bash -l {0}
timeout-minutes: 30
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/unittests_old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Conda config
run: echo -e "channels:\n - conda-forge\n" > .condarc
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.9'
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
activate-environment: my-env
miniforge-version: latest
condarc-file: .condarc
environment-file: .ci_support/environment-old.yml
use-mamba: true
- name: Test
shell: bash -l {0}
timeout-minutes: 30
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.2
rev: v0.6.4
hooks:
- id: ruff
name: ruff lint
Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ classifiers = [
dependencies = [
"ase==3.23.0",
"numpy==2.1.1",
"scipy==1.14.0",
"scipy==1.14.1",
]
dynamic = ["version"]

Expand All @@ -39,23 +39,23 @@ Repository = "https://github.com/pyiron/structuretoolkit"
dscribe = ["dscribe==2.1.1"]
grainboundary = [
"aimsgb==1.1.1",
"pymatgen==2024.6.10",
"pymatgen==2024.9.10",
]
pyscal = ["pyscal3==3.2.6"]
pyscal = ["pyscal3==3.2.7"]
nglview = ["nglview==3.1.2"]
matplotlib = ["matplotlib==3.9.1"]
plotly = ["plotly==5.22.0"]
clusters = ["scikit-learn==1.5.1"]
matplotlib = ["matplotlib==3.9.2"]
plotly = ["plotly==5.24.0"]
clusters = ["scikit-learn==1.5.2"]
symmetry = ["spglib==2.5.0"]
surface = [
"spglib==2.5.0",
"pymatgen==2024.6.10",
"pymatgen==2024.9.10",
]
phonopy = [
"phonopy==2.26.6",
"spglib==2.5.0",
]
pyxtal = ["pyxtal==0.6.7"]
pyxtal = ["pyxtal==1.0.3"]

[tool.setuptools.packages.find]
include = ["structuretoolkit*"]
Expand Down
21 changes: 12 additions & 9 deletions structuretoolkit/analyse/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def get_distances_array(
p2: Optional[np.ndarray] = None,
mic: bool = True,
vectors: bool = False,
):
) -> np.ndarray:
"""
Return distance matrix of every position in p1 with every position in
p2. If p2 is not set, it is assumed that distances between all
Expand All @@ -19,13 +19,14 @@ def get_distances_array(
returned.
Args:
p1 (numpy.ndarray/list): Nx3 array of positions
p2 (numpy.ndarray/list): Nx3 array of positions
mic (bool): minimum image convention
vectors (bool): return vectors instead of distances
structure (ase.atoms.Atoms): The structure object
p1 (numpy.ndarray/list, optional): Nx3 array of positions. Defaults to None.
p2 (numpy.ndarray/list, optional): Nx3 array of positions. Defaults to None.
mic (bool, optional): Minimum image convention. Defaults to True.
vectors (bool, optional): Return vectors instead of distances. Defaults to False.
Returns:
numpy.ndarray: NxN if vector=False and NxNx3 if vector=True
"""
if p1 is None and p2 is not None:
p1 = p2
Expand All @@ -48,16 +49,18 @@ def get_distances_array(
return find_mic(structure=structure, v=diff_relative, vectors=vectors)


def find_mic(structure: Atoms, v: np.ndarray, vectors: bool = True):
def find_mic(structure: Atoms, v: np.ndarray, vectors: bool = True) -> np.ndarray:
"""
Find vectors following minimum image convention (mic). In principle this
function does the same as ase.geometry.find_mic
Args:
v (list/numpy.ndarray): 3d vector or a list/array of 3d vectors
structure (ase.atoms.Atoms): The structure object
v (numpy.ndarray/list): 3d vector or a list/array of 3d vectors
vectors (bool): Whether to return vectors (distances are returned if False)
Returns: numpy.ndarray of the same shape as input with mic
Returns:
numpy.ndarray: numpy.ndarray of the same shape as input with mic
"""
if any(structure.pbc):
v = np.einsum("ji,...j->...i", np.linalg.inv(structure.cell), v)
Expand Down
25 changes: 25 additions & 0 deletions structuretoolkit/analyse/dscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ def soap_descriptor_per_atom(
only_physical_cores: bool = False,
verbose: bool = False,
) -> np.ndarray:
"""
Calculates the SOAP descriptor for each atom in the given structure.
Args:
structure (ase.atoms.Atoms): The atomic structure.
r_cut (float, optional): The cutoff radius. Defaults to None.
n_max (int, optional): The maximum number of radial basis functions. Defaults to None.
l_max (int, optional): The maximum degree of spherical harmonics. Defaults to None.
sigma (float, optional): The width parameter for the Gaussian-type orbital. Defaults to 1.0.
rbf (str, optional): The radial basis function. Defaults to "gto".
weighting (np.ndarray, optional): The weighting coefficients for the radial basis functions. Defaults to None.
average (str, optional): The type of averaging. Defaults to "off".
compression (dict, optional): The compression settings. Defaults to {"mode": "off", "species_weighting": None}.
species (list, optional): The list of chemical symbols. Defaults to None.
periodic (bool, optional): Whether the system is periodic. Defaults to True.
sparse (bool, optional): Whether to use sparse matrices. Defaults to False.
dtype (str, optional): The data type of the output. Defaults to "float64".
centers (np.ndarray, optional): The centers for the descriptor calculation. Defaults to None.
n_jobs (int, optional): The number of parallel jobs. Defaults to 1.
only_physical_cores (bool, optional): Whether to use only physical cores. Defaults to False.
verbose (bool, optional): Whether to print verbose output. Defaults to False.
Returns:
np.ndarray: The SOAP descriptor for each atom.
"""
from dscribe.descriptors import SOAP

if species is None:
Expand Down
Loading

0 comments on commit 8114457

Please sign in to comment.