StatsBase.jl
StatsBase.jl copied to clipboard
silent failures with push! and binindex with out of range data values
Hi all,
I have been having a lot of fun with Julia drawing heatmaps using the StatsBase histogram package.
I have only just realised that push!
silently fails when given out of range data.
The "unix tradition" tends to be "Assume success unless told otherwise".
The silent failures from push! caused problems - especially around the [open,close) boundaries.
Please update the documentation if this is a "feature" to warn other users!
using Base.Test
using StatsBase
h = Histogram( (0.0:0.1:1.0, 0.0:0.1:1.0), :left )
idx = StatsBase.binindex(h,(1.0,1.0))
@test checkbounds(Bool,h.weights,idx...) == false
push!(h,(1.0,1.0)) #silently does nothing - which is surprising
idx = StatsBase.binindex(h,(0.0,0.0))
@test checkbounds(Bool,h.weights,idx...) == true
@test h.weights[idx...] == 0
push!(h,(0.0,0.0))
@test h.weights[idx...] == 1