Skip to content

Commit

Permalink
Add support for ase >= 3.23 and Python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
PicoCentauri committed Feb 19, 2025
1 parent 701e924 commit 0ef28b1
Show file tree
Hide file tree
Showing 21 changed files with 113 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/architecture-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- run: pip install tox

- name: run architecture tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- run: pip install tox

- name: Test build integrity
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: install dependencies
run: python -m pip install tox
- name: build documentation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- run: pip install tox

- name: Lint the code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- run: python -m pip install tox
- name: Build package
run: tox -e build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
- os: ubuntu-22.04
python-version: "3.9"
- os: ubuntu-22.04
python-version: "3.12"
python-version: "3.13"
- os: macos-14
python-version: "3.12"
python-version: "3.13"
# To be restored once we figure out the issue with the windows build
# - os: windows-2019
# python-version: "3.12"
# python-version: "3.13"

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.12"
python: "3.13"
rust: "1.75"
jobs:
pre_build:
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ sphinx >= 7
sphinxcontrib-bibtex
sphinx-gallery
sphinx-toggleprompt
setuptools # required for sphinxcontrib-bibtex together with Python 3.12
setuptools # required for sphinxcontrib-bibtex together with Python 3.13
tomli
6 changes: 4 additions & 2 deletions docs/src/dev-docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ Unreleased

.. Possible sections for each release:
.. Added
.. #####
Added
#####

- Added support for Python 3.13 and ase >= 3.23

.. Fixed
.. #####
Expand Down
1 change: 1 addition & 0 deletions docs/src/dev-docs/utils/data/readers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ASE

This section describes the parsers for the ASE library.

.. autofunction:: metatrain.utils.data.readers.ase.read
.. autofunction:: metatrain.utils.data.readers.ase.read_systems
.. autofunction:: metatrain.utils.data.readers.ase.read_energy
.. autofunction:: metatrain.utils.data.readers.ase.read_generic
Expand Down
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ description = "Training and evaluating machine learning models for atomistic sys
authors = [{name = "metatrain developers"}]

dependencies = [
"ase < 3.23.0",
"ase",
"metatensor-learn==0.3.1",
"metatensor-operations==0.3.1",
"metatensor-torch==0.7.2",
"jsonschema",
"omegaconf",
"python-hostlist",
"torch",
"vesin",
"numpy < 2.0.0"
]

keywords = ["machine learning", "molecular modeling"]
Expand All @@ -44,7 +42,7 @@ homepage = "https://metatensor.github.io/metatrain"
documentation = "https://metatensor.github.io/metatrain"
repository = "https://github.com/metatensor/metatrain"
issues = "https://github.com/metatensor/metatrain/issues"
changelog = "https://metatensor.github.io/metatrain/latest/references/changelog.html"
changelog = "https://metatensor.github.io/metatrain/latest/dev-docs/changelog.html"

[project.scripts]
mtt = "metatrain.__main__:main"
Expand Down Expand Up @@ -130,7 +128,7 @@ follow_imports = 'skip'
ignore_missing_imports = true

[tool.pytest.ini_options]
# ignore" a bunch of internal warnings with Python 3.12 and PyTorch
# ignore" a bunch of internal warnings with Python 3.13 and PyTorch
filterwarnings = [
"ignore:ast.Str is deprecated and will be removed in Python 3.14:DeprecationWarning",
"ignore:Attribute s is deprecated and will be removed in Python 3.14:DeprecationWarning",
Expand Down
8 changes: 4 additions & 4 deletions src/metatrain/gap/tests/test_regression.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import copy
import random

import ase.io
import metatensor.torch
import numpy as np
import torch
Expand All @@ -10,6 +9,7 @@
from metatrain.gap import GAP, Trainer
from metatrain.utils.data import Dataset, DatasetInfo
from metatrain.utils.data.readers import read_systems, read_targets
from metatrain.utils.data.readers.ase import read
from metatrain.utils.data.target_info import get_energy_target_info

from . import DATASET_ETHANOL_PATH, DATASET_PATH, DEFAULT_HYPERS
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_regression_train_and_invariance():
assert torch.allclose(output["mtt::U0"].block().values, expected_output, rtol=0.3)

# Tests that the model is rotationally invariant
system = ase.io.read(DATASET_PATH)
system = read(DATASET_PATH)
system.numbers = np.ones(len(system.numbers))

original_system = copy.deepcopy(system)
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_ethanol_regression_train_and_invariance():

# Predict on the first five systems
output = gap(systems[:5], {"energy": gap.outputs["energy"]})
data = ase.io.read(DATASET_ETHANOL_PATH, ":5", format="extxyz")
data = read(DATASET_ETHANOL_PATH, ":5", format="extxyz")

expected_output = torch.tensor([[i.info["energy"]] for i in data])
assert torch.allclose(output["energy"].block().values, expected_output, rtol=0.1)
Expand All @@ -176,7 +176,7 @@ def test_ethanol_regression_train_and_invariance():
# expected_forces = torch.vstack([torch.Tensor(i.arrays["forces"]) for i in data])

# Tests that the model is rotationally invariant
system = ase.io.read(DATASET_ETHANOL_PATH)
system = read(DATASET_ETHANOL_PATH)

original_system = copy.deepcopy(system)
system.rotate(48, "y")
Expand Down
6 changes: 3 additions & 3 deletions src/metatrain/pet/tests/test_pet_compatibility.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import ase
import pytest
import torch
from metatensor.torch.atomistic import (
Expand All @@ -18,6 +17,7 @@
from metatrain.pet.utils import systems_to_batch_dict
from metatrain.utils.architectures import get_default_hypers
from metatrain.utils.data import DatasetInfo
from metatrain.utils.data.readers.ase import read
from metatrain.utils.data.target_info import get_energy_target_info
from metatrain.utils.neighbor_lists import get_system_with_neighbor_lists

Expand Down Expand Up @@ -57,7 +57,7 @@ def test_batch_dicts_compatibility(cutoff):
"""Tests that the batch dict computed with internal MTM routines
is consitent with PET implementation."""

structure = ase.io.read(DATASET_PATH)
structure = read(DATASET_PATH)
atomic_types = sorted(set(structure.numbers))
system = systems_to_torch(structure)
options = NeighborListOptions(cutoff=cutoff, full_list=True, strict=True)
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_predictions_compatibility(cutoff):
"""Tests that predictions of the MTM implemetation of PET
are consistent with the predictions of the original PET implementation."""

structure = ase.io.read(DATASET_PATH)
structure = read(DATASET_PATH)

dataset_info = DatasetInfo(
length_unit="Angstrom",
Expand Down
8 changes: 4 additions & 4 deletions src/metatrain/soap_bpnn/tests/test_equivariance.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import copy

import ase.io
import numpy as np
import pytest
import torch
from metatensor.torch.atomistic import System, systems_to_torch

from metatrain.soap_bpnn import SoapBpnn
from metatrain.utils.data import DatasetInfo
from metatrain.utils.data.readers.ase import read
from metatrain.utils.data.target_info import (
get_energy_target_info,
get_generic_target_info,
Expand All @@ -31,7 +31,7 @@ def test_rotational_invariance():
)
model = SoapBpnn(MODEL_HYPERS, dataset_info)

system = ase.io.read(DATASET_PATH)
system = read(DATASET_PATH)
original_system = copy.deepcopy(system)
system.rotate(48, "y")

Expand Down Expand Up @@ -77,7 +77,7 @@ def test_equivariance_rotations(o3_lambda, o3_sigma):
)
model = SoapBpnn(MODEL_HYPERS, dataset_info)

system = ase.io.read(DATASET_PATH)
system = read(DATASET_PATH)
original_system = systems_to_torch(system)
rotation = get_random_rotation()
rotated_system = rotate_system(original_system, rotation)
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_equivariance_inversion(o3_lambda, o3_sigma):
)
model = SoapBpnn(MODEL_HYPERS, dataset_info)

system = ase.io.read(DATASET_PATH)
system = read(DATASET_PATH)
original_system = systems_to_torch(system)
inverted_system = System(
positions=original_system.positions * (-1),
Expand Down
Loading

0 comments on commit 0ef28b1

Please sign in to comment.