ciemss / pyciemss

Causal and probabilistic reasoning with continuous time dynamical systems
Other
17 stars 6 forks source link

adding check on num_samples #455

Closed sabinala closed 8 months ago

sabinala commented 8 months ago

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

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

Closes #451

sabinala commented 8 months ago

Please let me know if there's a reason not to this using an assert statement. We had discussed writing a test for this, but I think this is sufficient and simpler.

SamWitty commented 8 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 8 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 8 months ago

Can you also add a unit test that gives a nonpositive interger and a float and a tensor int to num_samples and assert that a ValueError is raised?

sabinala commented 8 months ago

@djinnome unit tests for sample and ensemble_sample error messages are now in their own files inside of tests and all tests are passing!