Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Oct 30, 2023
1 parent 039ba23 commit 12fe21d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pypesto/profile/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def create_instance(
def validate(self):
"""Check if options are valid.
Raise ``ValueError`` if not.
Raises ``ValueError`` if current settings aren't valid.
"""
if self.min_step_size <= 0:
raise ValueError("min_step_size must be > 0.")
Expand Down
23 changes: 23 additions & 0 deletions test/profile/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from copy import deepcopy

import numpy as np
import pytest
from numpy.testing import assert_almost_equal

import pypesto
Expand Down Expand Up @@ -412,3 +413,25 @@ def test_approximate_ci():
# bound value
assert np.isclose(lb, -3)
assert np.isclose(ub, 9)


def test_options_valid():
"""Test ProfileOptions validity checks."""
# default settings are valid
profile.ProfileOptions()

# try to set invalid values
with pytest.raises(ValueError):
profile.ProfileOptions(default_step_size=-1)
with pytest.raises(ValueError):
profile.ProfileOptions(default_step_size=1, min_step_size=2)
with pytest.raises(ValueError):
profile.ProfileOptions(
default_step_size=2,
min_step_size=1,
)
with pytest.raises(ValueError):
profile.ProfileOptions(
min_step_size=2,
max_step_size=1,
)

0 comments on commit 12fe21d

Please sign in to comment.