-
Notifications
You must be signed in to change notification settings - Fork 256
100% Test coverage all (?) distributions #1399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
fbffcf0
0d7c245
264487e
96f7df8
f2b43c2
2b07b7a
5abd8a2
bfcc51c
3aa42a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,6 +105,7 @@ void test_ignore_policy(RealType) | |
| //std::cout << "pdf(ignore_error_arcsine(-1, +1), std::numeric_limits<RealType>::infinity()) = " << pdf(ignore_error_arcsine(-1, +1), std::numeric_limits<RealType>::infinity()) << std::endl; | ||
| // Outputs: pdf(ignore_error_arcsine(-1, +1), std::numeric_limits<RealType>::infinity()) = 1.#QNAN | ||
| } | ||
| BOOST_CHECK((boost::math::isnan)(pdf(ignore_error_arcsine(0, 1), std::numeric_limits<RealType>::infinity()))); // x == infinity | ||
| BOOST_CHECK((boost::math::isnan)(pdf(ignore_error_arcsine(-1, 1), std::numeric_limits<RealType>::infinity()))); // x == infinity | ||
| BOOST_CHECK((boost::math::isnan)(pdf(ignore_error_arcsine(0, 1), static_cast <RealType>(-2)))); // x < xmin | ||
|
|
@@ -120,9 +121,31 @@ void test_ignore_policy(RealType) | |
| BOOST_CHECK((boost::math::isnan)(logpdf(ignore_error_arcsine(0, 1), static_cast <RealType>(+2)))); // x > x_max | ||
| BOOST_CHECK((boost::math::isnan)(logpdf(ignore_error_arcsine(-1, 1), static_cast <RealType>(+2)))); // x > x_max | ||
|
|
||
| // CDF | ||
| BOOST_CHECK((boost::math::isnan)(cdf(ignore_error_arcsine(0, 1), std::numeric_limits<RealType>::infinity()))); // x == infinity | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My only comment here, is that generally I would prefer to see a BOOST_CHECK_THROW and verify that the correct exception is thrown: as long as we're getting the right error handler called (and hence correct exception thrown) then we know it's guaranteed we'll get a NaN when exceptions are off, where as a NaN when exceptions are off does not guarantee the correct exception type when they're on. Hope that makes sense! It wouldn't hurt to do both of course, but probably the only time we actually NEED both is to check for the correct sign on infinities when an overflow_error is raised. One final really picky point: we should really hide use of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The reason I did both is because we never actually hit the
Why does the BOOST_MATH_IF_CONSTEXPR need added?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Strictly speaking it's not required and we could use an |
||
| BOOST_CHECK((boost::math::isnan)(cdf(ignore_error_arcsine(-1, 1), std::numeric_limits<RealType>::infinity()))); // x == infinity | ||
| BOOST_CHECK((boost::math::isnan)(cdf(ignore_error_arcsine(0, 1), static_cast <RealType>(-2)))); // x < xmin | ||
| BOOST_CHECK((boost::math::isnan)(cdf(ignore_error_arcsine(-1, 1), static_cast <RealType>(-2)))); // x < xmin | ||
| BOOST_CHECK((boost::math::isnan)(cdf(ignore_error_arcsine(0, 1), static_cast <RealType>(+2)))); // x > x_max | ||
| BOOST_CHECK((boost::math::isnan)(cdf(ignore_error_arcsine(-1, 1), static_cast <RealType>(+2)))); // x > x_max | ||
| BOOST_CHECK((boost::math::isnan)(cdf(complement(ignore_error_arcsine(0, 1), std::numeric_limits<RealType>::infinity())))); // x == infinity | ||
| BOOST_CHECK((boost::math::isnan)(cdf(complement(ignore_error_arcsine(0, 1), static_cast <RealType>(-2))))); // x < xmin | ||
|
|
||
| // Quantile | ||
| BOOST_CHECK((boost::math::isnan)(quantile(ignore_error_arcsine(0, 1), std::numeric_limits<RealType>::infinity()))); // p == infinity | ||
| BOOST_CHECK((boost::math::isnan)(quantile(ignore_error_arcsine(0, 1), static_cast<RealType>(-1)))); // p < 0 | ||
| BOOST_CHECK((boost::math::isnan)(quantile(ignore_error_arcsine(0, 1), static_cast<RealType>(2)))); // p > 1 | ||
| BOOST_CHECK((boost::math::isnan)(quantile(complement(ignore_error_arcsine(0, 1), std::numeric_limits<RealType>::infinity())))); // q == infinity | ||
| BOOST_CHECK((boost::math::isnan)(quantile(complement(ignore_error_arcsine(0, 1), static_cast<RealType>(-1))))); // q < 0 | ||
| BOOST_CHECK((boost::math::isnan)(quantile(complement(ignore_error_arcsine(0, 1), static_cast<RealType>(2))))); // q > 1 | ||
|
|
||
| // Mean | ||
| BOOST_CHECK((boost::math::isnan)(mean(ignore_error_arcsine(-nan, 0)))); | ||
| BOOST_CHECK((boost::math::isnan)(mean(ignore_error_arcsine(+nan, 0)))); | ||
|
|
||
| // Median | ||
| BOOST_CHECK((boost::math::isnan)(median(ignore_error_arcsine(-nan, 0)))); | ||
| BOOST_CHECK((boost::math::isnan)(median(ignore_error_arcsine(+nan, 0)))); | ||
|
|
||
| if (std::numeric_limits<RealType>::has_infinity) | ||
| { | ||
|
|
@@ -276,7 +299,8 @@ void test_spots(RealType) | |
| BOOST_CHECK_EQUAL(variance(arcsine_01), 0.125); // 1/8 = 0.125 | ||
| BOOST_CHECK_CLOSE_FRACTION(standard_deviation(arcsine_01), one_div_root_two<double>() / 2, tolerance); // 1/ sqrt(s) = 0.35355339059327379 | ||
| BOOST_CHECK_EQUAL(skewness(arcsine_01), 0); // | ||
| BOOST_CHECK_EQUAL(kurtosis_excess(arcsine_01), -1.5); // 3/2 | ||
| BOOST_CHECK_EQUAL(kurtosis_excess(arcsine_01), -1.5); // -3/2 | ||
| BOOST_CHECK_EQUAL(kurtosis(arcsine_01), 1.5); // 3/2 | ||
| BOOST_CHECK_EQUAL(support(arcsine_01).first, 0); // | ||
| BOOST_CHECK_EQUAL(range(arcsine_01).first, 0); // | ||
| BOOST_CHECK_THROW(mode(arcsine_01), std::domain_error); // Two modes at x_min and x_max, so throw instead. | ||
|
|
@@ -374,8 +398,8 @@ void test_spots(RealType) | |
|
|
||
| BOOST_CHECK_EQUAL(variance(as_m11), 0.5); // 1 - (-1) = 2 ^ 2 = 4 /8 = 0.5 | ||
| BOOST_CHECK_EQUAL(skewness(as_m11), 0); // | ||
| BOOST_CHECK_EQUAL(kurtosis_excess(as_m11), -1.5); // 3/2 | ||
|
|
||
| BOOST_CHECK_EQUAL(kurtosis_excess(as_m11), -1.5); // -3/2 | ||
| BOOST_CHECK_EQUAL(kurtosis(as_m11), 1.5); // 3/2 | ||
|
|
||
| BOOST_CHECK_CLOSE_FRACTION(pdf(as_m11, 0.05), static_cast<RealType>(0.31870852113797122803869876869296281629727218095644L), tolerance); | ||
| BOOST_CHECK_CLOSE_FRACTION(pdf(as_m11, 0.5), static_cast<RealType>(0.36755259694786136634088433220864629426492432024443L), tolerance); | ||
|
|
@@ -428,7 +452,8 @@ void test_spots(RealType) | |
| BOOST_CHECK_EQUAL(median(as_m2m1), -1.5); // 1 / (1 + 1) = 1/2 exactly. | ||
| BOOST_CHECK_EQUAL(variance(as_m2m1), 0.125); | ||
| BOOST_CHECK_EQUAL(skewness(as_m2m1), 0); // | ||
| BOOST_CHECK_EQUAL(kurtosis_excess(as_m2m1), -1.5); // 3/2 | ||
| BOOST_CHECK_EQUAL(kurtosis(as_m2m1), 1.5); // 3/2 | ||
| BOOST_CHECK_EQUAL(kurtosis_excess(as_m2m1), -1.5); // -3/2 | ||
|
|
||
| BOOST_CHECK_CLOSE_FRACTION(pdf(as_m2m1, -1.95), static_cast<RealType>(1.4605059227421865250256574657088244053723856445614L), 4 * tolerance); | ||
| BOOST_CHECK_CLOSE_FRACTION(pdf(as_m2m1, -1.5), static_cast<RealType>(0.63661977236758134307553505349005744813783858296183L), tolerance); | ||
|
|
@@ -615,7 +640,8 @@ void test_spots(RealType) | |
| BOOST_CHECK_EQUAL(variance(as), 0.125); //0.125 | ||
| BOOST_CHECK_CLOSE_FRACTION(standard_deviation(as), one_div_root_two<double>() / 2, std::numeric_limits<double>::epsilon()); // 0.353553 | ||
| BOOST_CHECK_EQUAL(skewness(as), 0); // | ||
| BOOST_CHECK_EQUAL(kurtosis_excess(as), -1.5); // 3/2 | ||
| BOOST_CHECK_EQUAL(kurtosis(as), 1.5); // 3/2 | ||
| BOOST_CHECK_EQUAL(kurtosis_excess(as), -1.5); // -3/2 | ||
| BOOST_CHECK_EQUAL(support(as).first, 0); // | ||
| BOOST_CHECK_EQUAL(range(as).first, 0); // | ||
| BOOST_CHECK_THROW(mode(as), std::domain_error); // Two modes at x_min and x_max, so throw instead. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind this change, but the two lines are equivalent I think, so if we end up with too many of these it gets harder to review the PR.
That said, I wonder if we should just simplify the whole thing down to:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW I get the point that the others have a missing set of ()'s. I wonder if those would simplify down to one liners too and be easier to read as a result?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was worried about that. For now, I'll leave these alone and just fix any missing ()'s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, there's quite a few of these issues. For example, in
exponential.hppall the checks are written as0 == detail::verify_lambda(function, lambda, &result, Policy()).Would this work? Wouldn't the function then return true/false when we want to return the variable
resultwhich is defined asThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see an issue there? Arguably it should be
false == detail::verify_lambda(function, lambda, &result, Policy())but even that's hardly a necessary change?I'm looking specifically at the helpers that compound two or more checks (and return a bool), for example:
Could be simplified to:
?