Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

histogram error #4060

Closed
smartinsightsfromdata opened this issue Jan 23, 2022 · 3 comments
Closed

histogram error #4060

smartinsightsfromdata opened this issue Jan 23, 2022 · 3 comments
Labels

Comments

@smartinsightsfromdata
Copy link

smartinsightsfromdata commented Jan 23, 2022

I am using Julia 1.7.1 on Ubuntu 20.04. I use jupyterlab.

I get an error every time I use histogram, as in:

using StatsPlots
myrandomvector = randn(100)
StatsPlots.histogram(myrandomvector)

This is the error message:

MethodError: no method matching floatrange(::Type{Float64}, ::Int64, ::Int64, ::Float64, ::Int64)
Closest candidates are:
  floatrange(::Type{T}, ::Integer, ::Integer, ::Integer, ::Integer) where T at ~/packages/julias/julia-1.7/share/julia/base/twiceprecision.jl:370
  floatrange(::AbstractFloat, ::AbstractFloat, ::Real, ::AbstractFloat) at ~/packages/julias/julia-1.7/share/julia/base/twiceprecision.jl:384

Stacktrace:
  [1] floatrange(a::Float64, st::Float64, len::Float64, divisor::Float64)
    @ Base ./twiceprecision.jl:392
  [2] histrange(lo::Float64, hi::Float64, n::Int64, closed::Symbol)
    @ StatsBase ~/.julia/packages/StatsBase/DU1bT/src/hist.jl:99
  [3] histrange(v::Vector{Float64}, n::Int64, closed::Symbol)
    @ StatsBase ~/.julia/packages/StatsBase/DU1bT/src/hist.jl:39
  [4] _hist_edge
    @ ~/.julia/packages/Plots/FKcum/src/recipes.jl:806 [inlined]
  [5] _hist_edge
    @ ~/.julia/packages/Plots/FKcum/src/recipes.jl:808 [inlined]
  [6] JuliaPlots/StatsPlots.jl#205
    @ ~/.julia/packages/Plots/FKcum/src/recipes.jl:822 [inlined]
  [7] map
    @ ./tuple.jl:221 [inlined]
  [8] _hist_edges
    @ ~/.julia/packages/Plots/FKcum/src/recipes.jl:822 [inlined]
  [9] _make_hist(vs::Tuple{Vector{Float64}}, binning::Symbol; normed::Bool, weights::Nothing)
    @ Plots ~/.julia/packages/Plots/FKcum/src/recipes.jl:841
 [10] macro expansion
    @ ~/.julia/packages/Plots/FKcum/src/recipes.jl:865 [inlined]
 [11] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{Val{:barhist}}, x::Any, y::Any, z::Any)
    @ Plots ~/.julia/packages/RecipesBase/qpxEX/src/RecipesBase.jl:289
 [12] _process_seriesrecipe(plt::Any, plotattributes::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/bexlW/src/series_recipe.jl:50
 [13] _process_seriesrecipe(plt::Any, plotattributes::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/bexlW/src/series_recipe.jl:60
 [14] _process_seriesrecipes!(plt::Any, kw_list::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/bexlW/src/series_recipe.jl:27
 [15] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/bexlW/src/RecipesPipeline.jl:97
 [16] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
    @ Plots ~/.julia/packages/Plots/FKcum/src/plot.jl:172
 [17] plot(args::Any; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
    @ Plots ~/.julia/packages/Plots/FKcum/src/plot.jl:58
 [18] histogram(args::Any; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
    @ Plots ~/.julia/packages/RecipesBase/qpxEX/src/RecipesBase.jl:410
 [19] histogram(args::Any)
    @ Plots ~/.julia/packages/RecipesBase/qpxEX/src/RecipesBase.jl:410
 [20] top-level scope
    @ In[21]:2
 [21] eval
    @ ./boot.jl:373 [inlined]
 [22] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:1196

The surprinsing thing is that StatsPlots.ea_histogram(myrandomvector) works!

@sethaxen
Copy link
Member

histogram is defined in Plots.jl, while ea_histogram is defined here, so this doesn't appear to be a StatsPlots issue. Also, I was unable to replicate.

@sethaxen sethaxen transferred this issue from JuliaPlots/StatsPlots.jl Jan 24, 2022
@smartinsightsfromdata
Copy link
Author

@sethaxen Thank you for looking into this. I just tried with Julia 1.6.5 and all works.

But certainly there is a problem somewhere. In fact I know other have had problems. See here: https://discourse.julialang.org/t/methoderror-no-method-matching-floatrange-when-running-histogram-1-7-0-win-11-21h2-amd-5900hx/72679

@smartinsightsfromdata
Copy link
Author

I think I found the cause of my problems. In the repo I downloaded from Julia Academy there were old Manifest / Project files that were creating errors.

I deleted them and now everything works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants