New Distribution Testing Infastructure#1400
Conversation
|
Thanks for this,
I guess so, and actually we can check the values are correct too I think? PDF should be zero at +-INF and CDF should be zero at -INF and 1 at +INF. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1400 +/- ##
===========================================
- Coverage 95.61% 95.60% -0.01%
===========================================
Files 825 826 +1
Lines 68487 68501 +14
===========================================
+ Hits 65481 65489 +8
- Misses 3006 3012 +6
... and 4 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
I'm trying to write a function to test bad constructors. My idea was to pass in a vector of vectors where each element is a vector of invalid parameters. However, it's not working as I intended and I have no clue why. I'm first trying to do this for the arcsine distribution. I began by defining a new constructor from a vector BOOST_MATH_GPU_ENABLED arcsine_distribution(std::vector<RealType> params) : arcsine_distribution(params[0], params[1]) {}which just unpacks the vector and calls the original constructor. Then in std::vector<std::vector<RealType> > invalid_params = {{1, 0}, // x_min > x_max
{1, -1}};
test_invalid_parameters<arcsine_distribution, RealType>(invalid_params);The function template <template <typename...> typename Distribution, class Real>
void test_invalid_parameters(std::vector<std::vector<Real> > invalid_parameters)
{
typedef Distribution<Real> dist;
std::vector<Real> params;
for (unsigned i=0; i<invalid_parameters.size(); i++)
{
params = invalid_parameters[i];
BOOST_CHECK_THROW(dist(params), std::domain_error); // This should throw an error, but doesn't!
BOOST_CHECK_THROW(dist x(params), std::domain_error); // This throws a domain_error
BOOST_CHECK_THROW(boost::math::pdf(dist(params), 0.5), std::domain_error); // This also throws a domain_error
}
}I don't understand why |
That's not clear to me either, I always step through the code in situations like this. BTW I'd rather not start adding lots of new constructors just for testing purposes, although we could conceivably add a OK how about: make_distribution< binomial_distribution>({ 1.0, 2.0 }) |
This is exactly what I was looking for! Thanks for implementing this. I was over complicating things. |
|
Is there a way to only run the codecov report when I push a commit? I'm running all the tests and they don't really need to be run on every commit. |
No not really, not unless you temporarily disable the other runs in the github actions scripts: If you do that, make that one commit in it's own right, and then make sure you revert that commit before you're ready to merge. |
Currently, the new helper function,
test_invalid_support, only ensures that a domain error is thrown if the cdf, pdf, logcdf, logpdf or quantile is sampled outside the support of the distribution. I think there are still edge cases that need to be addressed. Here are my following thoughtsI've deleted some tests that I previously added for the arcsine distribution just to see if I am getting the same code coverage as before (100%).
Here's the code coverage report.
Here's an ongoing list of distributions that I've added generic testing for