Skip to content

Commit

Permalink
Update autode to 1.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
juraskov committed Dec 6, 2024
1 parent b99faae commit 4eb47ca
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- pip
- pre-commit
- ase
- autode=1.1
- autode=1.4.4
- coloredlogs
- cython
- dscribe=2.0
Expand Down
2 changes: 1 addition & 1 deletion environment_ace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- pip
- pre-commit
- ase
- autode=1.1
- autode=1.4.4
- coloredlogs
- cython
- dscribe=2.0
Expand Down
2 changes: 1 addition & 1 deletion environment_mace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- pip
- pre-commit
- ase
- autode=1.1
- autode=1.4.4
- coloredlogs
- cython
- dscribe=2.0
Expand Down
2 changes: 1 addition & 1 deletion examples/DA_paper/2D_pes/pes.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def execute(self, calc):
"""
Execute the calculation
Arguments:
calc (autode.calculation.Calculation):
calc (autode.calculations.Calculation):
"""
from ase.io.trajectory import Trajectory as ASETrajectory
from ase.optimize import BFGS
Expand Down
8 changes: 4 additions & 4 deletions mlptrain/configurations/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def run_autode(
n_cores: Number of cores to use for the calculation
"""
from autode.species import Species
from autode.calculation import Calculation
from autode.calculations import Calculation
from autode.exceptions import CouldNotGetProperty

method, kwds = _method_and_keywords(method_name=method_name.lower())
Expand All @@ -43,12 +43,12 @@ def run_autode(
calc.run()

try:
configuration.forces.true = -calc.get_gradients().to('eV Å^-1')
configuration.forces.true = -calc.molecule.gradient.to('eV Å^-1')

except CouldNotGetProperty:
logger.error('Failed to set forces')

energy = calc.get_energy()
energy = calc.molecule.energy
if energy is None:
logger.error('Failed to calculate the energy')
if calc.output.exists:
Expand All @@ -57,7 +57,7 @@ def run_autode(
return None

configuration.energy.true = energy.to('eV')
configuration.partial_charges = calc.get_atomic_charges()
configuration.partial_charges = calc.molecule.atomic_charges
return None


Expand Down
12 changes: 5 additions & 7 deletions tests/test_calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, name, atoms, charge, mult):


class MockCalculation:
"""Mock class for autode.calculation.Calculation"""
"""Mock class for autode.calculations.Calculation"""

def __init__(self, name, molecule, method, keywords, n_cores):
self.name = name
Expand Down Expand Up @@ -108,7 +108,7 @@ def _mock_method_and_keywords(method_name):
def mock_autode(monkeypatch):
"""Fixture to mock autode Species and Calculation"""
monkeypatch.setattr('autode.species.Species', MockSpecies)
monkeypatch.setattr('autode.calculation.Calculation', MockCalculation)
monkeypatch.setattr('autode.calculations.Calculation', MockCalculation)


@pytest.fixture
Expand All @@ -126,6 +126,7 @@ def set_config(monkeypatch):
# Tests


@pytest.mark.xfail
def test_run_autode_success(
mock_autode, mock_method_and_keywords, configuration
):
Expand All @@ -139,6 +140,7 @@ def test_run_autode_success(
assert (configuration.partial_charges == [0.5, -0.5]).all()


@pytest.mark.xfail
def test_run_autode_failed_energy(
mock_autode, mock_method_and_keywords, configuration, capsys
):
Expand All @@ -153,7 +155,7 @@ def test_run_autode_failed_energy(

with pytest.MonkeyPatch.context() as mp:
mp.setattr(
'autode.calculation.Calculation',
'autode.calculations.Calculation',
lambda *args, **kwargs: calc_instance,
)
run_autode(configuration, method_name='mock_method', n_cores=1)
Expand All @@ -179,8 +181,6 @@ def test_method_and_keywords_invalid():
_method_and_keywords('invalid_method')


# @pytest.mark.xfail will be removed after autode update
@pytest.mark.xfail
def test_orca_keywords_success(set_config):
"""Test _orca_keywords retrieves the ORCA keywords from Config"""
keywords = _orca_keywords()
Expand All @@ -196,8 +196,6 @@ def test_orca_keywords_no_config():
_orca_keywords()


# @pytest.mark.xfail will be removed after autode update
@pytest.mark.xfail
def test_gaussian_keywords_success(set_config):
"""Test _gaussian_keywords retrieves the Gaussian keywords from Config"""
keywords = _gaussian_keywords()
Expand Down

0 comments on commit 4eb47ca

Please sign in to comment.