Skip to content

Commit

Permalink
improved warning management
Browse files Browse the repository at this point in the history
- ignore some warnings in pytest
- check for some gromacs.UsageWarning explicitly
  • Loading branch information
orbeckst committed Jun 17, 2024
1 parent 514fe0f commit 51a1e79
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
11 changes: 9 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ rmprefix = "release-"
file = "gromacs/_version.py"



[tool.black]
extend-exclude = "tests/(test_core|fileformats/test_convert)\\.py"
extend-exclude = "tests/(test_core|fileformats/test_convert)\\.py"


[tool.pytest.ini_options]
filterwarnings = [
"ignore::gromacs.AutoCorrectionWarning",
"ignore::gromacs.LowAccuracyWarning",
"ignore::numkit.LowAccuracyWarning",
]
46 changes: 27 additions & 19 deletions tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ def energy_minimize(solvate, low_performance):
TMPDIR, solvate_args = solvate
nt = 2 if low_performance else 0
with TMPDIR.as_cwd():
em_args = gromacs.setup.energy_minimize(
mdrun_args={"nt": nt},
integrator="steep",
emtol=5000,
maxwarn=1,
**solvate_args,
)
with pytest.warns(
gromacs.UsageWarning,
match="Unprocessed mdp option are interpreted as options for grompp",
):
em_args = gromacs.setup.energy_minimize(
mdrun_args={"nt": nt},
integrator="steep",
emtol=5000,
maxwarn=1,
**solvate_args,
)
return TMPDIR, em_args


Expand Down Expand Up @@ -106,18 +110,22 @@ def test_energy_minimize_custom_mdp(
TMPDIR, solvate_args = solvate
nt = 2 if low_performance else 0
with TMPDIR.as_cwd():
try:
em_args = gromacs.setup.energy_minimize(
mdrun_args={"nt": nt}, mdp=mdp, emtol=5000, **solvate_args
)
except gromacs.exceptions.GromacsError as err:
# sometimes the em does not converge at all, e.g. 5.02988e+04 on atom 3277;
# (happens on Travis Linux with Gromacs 4.6.5 but not locally or on Travis OSX) so we
# re-run with a ridiculous tolerance so that we can at least test that the whole
# function can run to completion
em_args = gromacs.setup.energy_minimize(
mdrun_args={"nt": nt}, mdp=mdp, emtol=6e4, **solvate_args
)
with pytest.warns(
gromacs.UsageWarning,
match="Unprocessed mdp option are interpreted as options for grompp",
):
try:
em_args = gromacs.setup.energy_minimize(
mdrun_args={"nt": nt}, mdp=mdp, emtol=5000, **solvate_args
)
except gromacs.exceptions.GromacsError as err:
# sometimes the em does not converge at all, e.g. 5.02988e+04 on atom 3277;
# (happens on Travis Linux with Gromacs 4.6.5 but not locally or on Travis OSX) so we
# re-run with a ridiculous tolerance so that we can at least test that the whole
# function can run to completion
em_args = gromacs.setup.energy_minimize(
mdrun_args={"nt": nt}, mdp=mdp, emtol=6e4, **solvate_args
)
assert os.path.exists(em_args["struct"])
assert os.path.exists(em_args["top"])
assert em_args["mainselection"] == '"Protein"'
Expand Down

0 comments on commit 51a1e79

Please sign in to comment.