From fe0ea168f3310f89635b3eb191a30c9a65afb2bd Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Fri, 8 Sep 2017 03:18:46 -0500 Subject: [PATCH] histogram: ensure the number of bins is finite --- src/recipes.jl | 2 +- test/runtests.jl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/recipes.jl b/src/recipes.jl index 61d3de87..876b3897 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -501,7 +501,7 @@ wand_edges(x...) = (warn("Load the StatPlots package in order to use :wand bins. function _auto_binning_nbins{N}(vs::NTuple{N,AbstractVector}, dim::Integer; mode::Symbol = :auto) _cl(x) = ceil(Int, NaNMath.max(x, one(x))) - _iqr(v) = quantile(v, 0.75) - quantile(v, 0.25) + _iqr(v) = (q = quantile(v, 0.75) - quantile(v, 0.25); q > 0 ? q : oftype(q, 1)) _span(v) = ignorenan_maximum(v) - ignorenan_minimum(v) n_samples = length(linearindices(first(vs))) diff --git a/test/runtests.jl b/test/runtests.jl index da7fcb05..3f471735 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -129,6 +129,9 @@ end @test Plots.ignorenan_extrema(axis) == (0.5, 7.5) end +@testset "NoFail" begin + histogram([1, 0, 0, 0, 0, 0]) +end # tests for preprocessing recipes