Skip to content

Commit

Permalink
mend
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradJohnston committed Nov 26, 2024
1 parent bedb26d commit 9831f66
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/aiida_pyscf/calculations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def validate_parameters(cls, value: Dict | None, _) -> str | None: # noqa: PLR0
)

if (scf_solver := mean_field.get('solver')) is not None:
valid_scf_solvers = ('DISS', 'CDIIS', 'EDIIS', 'ADIIS')
valid_scf_solvers = ('DIIS', 'CDIIS', 'EDIIS', 'ADIIS')
options = ' '.join(valid_scf_solvers)

if scf_solver is None:
Expand Down
22 changes: 21 additions & 1 deletion tests/calculations/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,27 @@ def test_invalid_parameters_mean_field_method(generate_calc_job, generate_inputs
parameters = {'mean_field': {'method': 'invalid'}}
inputs = generate_inputs_pyscf(parameters=parameters)

with pytest.raises(ValueError, match=r'Specified mean field method invalid is not supported'):
with pytest.raises(ValueError, match=r'Specified mean field method invalid is not supported, choose from: '
r'RKS RHF DKS DHF GKS GHF HF KS ROHF ROKS UKS UHF'):
generate_calc_job(PyscfCalculation, inputs=inputs)


def test_invalid_parameters_mean_field_solver(generate_calc_job, generate_inputs_pyscf):
"""Test validation of ``parameters.mean_field.solver``."""
parameters = {'mean_field': {'solver': 'invalid'}}
inputs = generate_inputs_pyscf(parameters=parameters)

with pytest.raises(ValueError, match=r'Invalid solver `invalid` specified in `mean_field.solver` parameters. '
r'Choose from: DIIS CDIIS EDIIS ADIIS'):
generate_calc_job(PyscfCalculation, inputs=inputs)


def test_invalid_parameters_mean_field_solver_diis(generate_calc_job, generate_inputs_pyscf):
"""Test logic to catch `DIIS` solver input for ``parameters.mean_field.solver``."""
parameters = {'mean_field': {'solver': 'DIIS'}}
inputs = generate_inputs_pyscf(parameters=parameters)

with pytest.raises(ValueError, match=r'`DIIS` is an alias for CDIIS in PySCF. Using `CDIIS` explicitly instead.'):
generate_calc_job(PyscfCalculation, inputs=inputs)


Expand Down

0 comments on commit 9831f66

Please sign in to comment.