# Dropdims for AxisArray throws "method too new"

**URL:** <https://discourse.julialang.org/t/dropdims-for-axisarray-throws-method-too-new/18042>\
**Category:** General Usage\
**Created:** [November 27, 2018, 1:08am UTC](https://discourse.julialang.org/t/dropdims-for-axisarray-throws-method-too-new/18042 "2018-11-27T01:08:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [November 27, 2018, 1:08am UTC](https://discourse.julialang.org/t/dropdims-for-axisarray-throws-method-too-new/18042/1 "2018-11-27T01:08:32Z")

</div>

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

```julia
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:

```julia
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?

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [November 27, 2018, 1:37am UTC](https://discourse.julialang.org/t/dropdims-for-axisarray-throws-method-too-new/18042/2 "2018-11-27T01:37:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [November 27, 2018, 1:39am UTC](https://discourse.julialang.org/t/dropdims-for-axisarray-throws-method-too-new/18042/3 "2018-11-27T01:39:08Z")

</div>

Here it is:

```julia
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&lt;:(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&lt;:Axis}) where Ax&lt;: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](#)

```

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [November 27, 2018, 1:48am UTC](https://discourse.julialang.org/t/dropdims-for-axisarray-throws-method-too-new/18042/4 "2018-11-27T01:48:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [November 27, 2018, 1:49am UTC](https://discourse.julialang.org/t/dropdims-for-axisarray-throws-method-too-new/18042/5 "2018-11-27T01:49:41Z")

</div>

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

```julia
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)

```

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [November 27, 2018, 1:50am UTC](https://discourse.julialang.org/t/dropdims-for-axisarray-throws-method-too-new/18042/6 "2018-11-27T01:50:57Z")

</div>

Hmm. I’m on

```julia
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?

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [November 27, 2018, 1:56am UTC](https://discourse.julialang.org/t/dropdims-for-axisarray-throws-method-too-new/18042/7 "2018-11-27T01:56:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [November 27, 2018, 1:58am UTC](https://discourse.julialang.org/t/dropdims-for-axisarray-throws-method-too-new/18042/8 "2018-11-27T01:58:30Z")

</div>

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](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.
