clbustos/statsample — pull request #36 by rdlugosz (2014-11-18 16:22:27+00:00)
Title: Prevent FloatDomainError on Histogram with span=0

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`.)

```
FloatDomainError: -Infinity
/Users/ryan/workspace/statsample/lib/statsample.rb:246:in `round'
/Users/ryan/workspace/statsample/lib/statsample.rb:246:in `nice'
/Users/ryan/workspace/statsample/lib/statsample/vector.rb:1004:in
`histogram'
/Users/ryan/workspace/statsample/lib/statsample/graph/histogram.rb:77:in
`pre_vis'
/Users/ryan/workspace/statsample/lib/statsample/graph/histogram.rb:107:in
`rubyvis_panel'
/Users/ryan/workspace/statsample/lib/statsample/graph/histogram.rb:177:in
`to_svg'
```