Skip to content

Commit

Permalink
Fix Python workflow (dftd4#251)
Browse files Browse the repository at this point in the history
* Fix macos version to macos-13
* Pin ASE version to <3.23 for Python 3.7
  • Loading branch information
marvinfriede authored Jul 28, 2024
1 parent c0457af commit 3a1c21e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/fortran-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
compiler: gnu
version: 8

- os: macos-latest
- os: macos-13
build: cmake
build-type: debug
compiler: gnu
Expand All @@ -36,7 +36,7 @@ jobs:
compiler: gnu
version: 9

- os: macos-latest
- os: macos-13
build: meson
build-type: debug
compiler: gnu
Expand Down Expand Up @@ -267,6 +267,11 @@ jobs:
create-args: >-
python=${{ matrix.python_v }}
- name: Install ase<3.23 for Python 3.7
if: matrix.python_v == '3.7'
run: |
micromamba install -y -c conda-forge "ase<3.23"
- name: Install GCC (OSX)
if: ${{ contains(matrix.os, 'macos') }}
run: |
Expand Down
20 changes: 16 additions & 4 deletions python/dftd4/test_ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pytest import approx


def test_ase_scand4():
def test_ase_scand4() -> None:
thr = 1.0e-6

forces = np.array(
Expand All @@ -47,11 +47,17 @@ def test_ase_scand4():

atoms.calc = DFTD4(method="SCAN").add_calculator(EMT())
assert approx(atoms.get_potential_energy(), abs=thr) == 3.6624398683434225
energies = [calc.get_potential_energy() for calc in atoms.calc.calcs]

if hasattr(atoms.calc, "calcs"):
calcs = atoms.calc.calcs
else:
calcs = atoms.calc.mixer.calcs

energies = [calc.get_potential_energy() for calc in calcs]
assert approx(energies, abs=thr) == [-0.021665446836610563, 3.684105315180033]


def test_ase_tpssd4():
def test_ase_tpssd4() -> None:
thr = 1.0e-6

forces = np.array(
Expand Down Expand Up @@ -79,5 +85,11 @@ def test_ase_tpssd4():

atoms.calc = DFTD4(method="TPSS").add_calculator(EMT())
assert approx(atoms.get_potential_energy(), abs=thr) == 4.864016486351274
energies = [calc.get_potential_energy() for calc in atoms.calc.calcs]

if hasattr(atoms.calc, 'calcs'):
calcs = atoms.calc.calcs
else:
calcs = atoms.calc.mixer.calcs

energies = [calc.get_potential_energy() for calc in calcs]
assert approx(energies, abs=thr) == [-0.24206732765720396, 5.106083814008478]
5 changes: 4 additions & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ dependencies = [
"cffi",
"numpy",
]
optional-dependencies.ase = ["ase"]
optional-dependencies.ase = [
"ase<3.23; python_version < '3.8'",
"ase; python_version >= '3.8'",
]
optional-dependencies.qcschema = ["qcelemental"]
optional-dependencies.pyscf = ["pyscf"]
optional-dependencies.test = [
Expand Down

0 comments on commit 3a1c21e

Please sign in to comment.