Dropdims for AxisArray throws "method too new"

As the title says, callind dropdims surprisingly raises a methoderror, while e.g. sum works OK:

using AxisArrays

a = AxisArray(rand(1, 20), :a, :b)

sum(a, dims=Axis{:a})  # works
dropdims(a, dims=Axis{:a})  # raises 'method may be too new'

The exception is, in full:

MethodError: no method matching axisdim(::Type{AxisArray{Float64,2,Array{Float64,2},Tuple{Axis{:a,Base.OneTo{Int64}},Axis{:b,Base.OneTo{Int64}}}}}, ::Type{Axis{:a,T} where T})
The applicable method may be too new: running in world age 37030, while current world is 40852.

I did find some discussions about this kind of error in general, but cannot get what’s the reason in this case and how to fix it. Not even sure if it’s a bug somewhere, or I should execute something before?

Looks like a bug, but can you post the full error output, including the stack trace?

Here it is:

MethodError: no method matching axisdim(::Type{AxisArray{Float64,2,Array{Float64,2},Tuple{Axis{:a,Base.OneTo{Int64}},Axis{:b,Base.OneTo{Int64}}}}}, ::Type{Axis{:a,T} where T})

The applicable method may be too new: running in world age 37030, while current world is 40852.
Closest candidates are:
axisdim(::Type{AxisArray{T,N,D,Ax}}, ::Type{#s5651} where #s5651<:(Axis{name,S} where S)) where {T, N, D, Ax, name} at /home/aplavin/.julia/packages/AxisArrays/G6pZY/src/core.jl:281 (method too new to be called from this world context.)
axisdim(!Matched::AxisArray, ::Type{Ax<:Axis}) where Ax<:Axis at /home/aplavin/.julia/packages/AxisArrays/G6pZY/src/core.jl:275
axisdim(!Matched::ImageAxes.StreamingContainer, ::Type{Axis{name,T} where T}) where name at /home/aplavin/.julia/packages/ImageAxes/l0FE8/src/ImageAxes.jl:251 (method too new to be called from this world context.)
in top-level scope at [base/none](#)
in at [base/none](#)
in #dropdims#25 at [AxisArrays/G6pZY/src/core.jl:458](#)
in _dropdims at [AxisArrays/G6pZY/src/core.jl:466](#)
in at [base/boot.jl:506](#)
in #s5651#7 at [AxisArrays/G6pZY/src/core.jl:275](#)

Works for me. Are you running this in a fresh REPL or have you done other stuff first? What’s your platform and Julia version?

Completely fresh repl, tried both in juno and in command line julia.
Platform:

Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

Hmm. I’m on

julia> versioninfo()
Julia Version 1.0.3-pre.0
Commit 4f6c8c8fa4* (2018-11-09 04:07 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)

Perhaps try a more recent Julia release?

Indeed, I updated to 1.0.2 and now it works. So, turns out to be an already-fixed bug.

I think there really is a bug, though, or at least the potential for one. This line: https://github.com/JuliaArrays/AxisArrays.jl/blob/master/src/core.jl#L275 involves relying on method dispatch inside the body of a generated function, which is not generally ok.

2 Likes