If a Histogram is created with a set of equal values (e.g., [3,3,3]) a FloatDomainError: -Infinity error will be raised when calling to_svg. This happens because the span calculated in Statsample::Util#nice is 0 (see stacktrace below).
It appears that the original code may have been guarding against this by testing !span, but this is incorrect and should be tested as span == 0. (This may have been a check against nil and not zero, but there are better ways to handle that (e.g., span.nil?) and it also seems that span could not be nil due to the lines of code immediately above, which would raise an error if either s or e were nil.)
If a Histogram is created with a set of equal values (e.g., [3,3,3]) a
FloatDomainError: -Infinity
error will be raised when callingto_svg
. This happens because the span calculated inStatsample::Util#nice
is 0 (see stacktrace below).It appears that the original code may have been guarding against this by testing
!span
, but this is incorrect and should be tested asspan == 0
. (This may have been a check againstnil
and not zero, but there are better ways to handle that (e.g.,span.nil?
) and it also seems that span could not benil
due to the lines of code immediately above, which would raise an error if eithers
ore
werenil
.)