Skip to content

Commit

Permalink
Merge pull request #68 from JohnHBrock/histogram_float32_fix
Browse files Browse the repository at this point in the history
Fixes calls to `histogram(...)` with arrays of `Float32`
  • Loading branch information
Evizero committed Aug 9, 2017
2 parents 53fa47d + 83d65b7 commit 572d4ab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common.jl
Expand Up @@ -6,7 +6,7 @@ round_up_tick{F<:AbstractFloat,R<:Real}(x::F,m::R) = x == 0. ? 0.: (x > 0 ? ceil
round_down_tick{F<:AbstractFloat,R<:Real}(x::F,m::R) = x == 0. ? 0.: (x > 0 ? floor(x, ceil_neg_log10(m)) : -ceil(-x, ceil_neg_log10(m)))
round_up_subtick{F<:AbstractFloat,R<:Real}(x::F,m::R) = x == 0. ? 0.: (x > 0 ? ceil(x, ceil_neg_log10(m)+1) : -floor(-x, ceil_neg_log10(m)+1))
round_down_subtick{F<:AbstractFloat,R<:Real}(x::F,m::R) = x == 0. ? 0.: (x > 0 ? floor(x, ceil_neg_log10(m)+1) : -ceil(-x, ceil_neg_log10(m)+1))
float_round_log10{F<:AbstractFloat,R<:Real}(x::F,m::R) = x == 0. ? 0.: (x > 0 ? round(x, ceil_neg_log10(m)+1)::Float64 : -round(-x, ceil_neg_log10(m)+1)::Float64)
float_round_log10{F<:AbstractFloat,R<:Real}(x::F,m::R) = x == 0. ? 0.: (x > 0 ? round(x, ceil_neg_log10(m)+1)::F : -round(-x, ceil_neg_log10(m)+1)::F)
float_round_log10{F<:AbstractFloat}(x::F) = x > 0 ? float_round_log10(x,x) : float_round_log10(x,-x)

function plotting_range{F<:AbstractFloat,R<:AbstractFloat}(xmin::F, xmax::R)
Expand Down
1 change: 1 addition & 0 deletions test/tst_plots.jl
Expand Up @@ -199,6 +199,7 @@ print(histogram(rand(1000), bins=5, title="Histogram"))
print(histogram(rand(1000), title="Histogram"))
print(histogram(rand(1000)*0.001, title="Histogram"))
print(histogram(rand(800) * 10000 - 115000, title="Histogram"))
print(histogram([0.1f0, 0.1f0, 0f0]))

print(spy(sprand(10,10,.15)))
print(spy(sprand(5,10,.15), width = 5))
Expand Down

0 comments on commit 572d4ab

Please sign in to comment.