Skip to content

Commit

Permalink
Merge pull request #1094 from drewm1980/drewm1980-better-assert-order…
Browse files Browse the repository at this point in the history
…-in-uniform

Reorder asserts for easier debugging.
  • Loading branch information
dhardy committed Mar 20, 2021
2 parents e23ac91 + cdb3280 commit 5760aed
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/distributions/uniform.rs
Expand Up @@ -827,11 +827,15 @@ macro_rules! uniform_float_impl {
{
let low = *low_b.borrow();
let high = *high_b.borrow();
assert!(low.all_lt(high), "Uniform::new called with `low >= high`");
assert!(
low.all_finite() && high.all_finite(),
"Uniform::new called with non-finite boundaries"
low.all_finite(),
"Uniform::new called with `low` non-finite."
);
assert!(
high.all_finite(),
"Uniform::new called with `high` non-finite."
);
assert!(low.all_lt(high), "Uniform::new called with `low >= high`");
let max_rand = <$ty>::splat(
(::core::$u_scalar::MAX >> $bits_to_discard).into_float_with_exponent(0) - 1.0,
);
Expand Down

0 comments on commit 5760aed

Please sign in to comment.