ciemss / pyciemss

Causal and probabilistic reasoning with continuous time dynamical systems
Other
12 stars 4 forks source link

adding check for num_iterations in calibrate #457

Closed sabinala closed 6 months ago

sabinala commented 6 months ago

This PR adds an assert statement (see code below) in calibrate that will give the error message: "num_iterations must be a positive integer." if num_iterations is not a positive integer.

# Check that num_iterations is a positive integer
assert isinstance(num_iterations, int) and num_iterations > 0, "num_iterations must be a positive integer."

Closes #456

SamWitty commented 6 months ago

@sabinala , as discussed in our call yesterday, could you please change these assertions to the following:

if condition:
    raise ValueError("description")
sabinala commented 6 months ago

@djinnome I've changed the assert statement to an if statement that raises a ValueError, and now this PR is ready for review.

djinnome commented 6 months ago

Hi @sabinala please add a unit test in test_interfaces.py that asserts that providing a float, or negative int or 0 or tensor(int) raises an error when used as input to the num_samples parameter, and providing a positive int does not raise an error.

sabinala commented 6 months ago

@djinnome unit tests for calibrate error messages are in their own file in tests, and all tests are passing here too.