AxisArrays.jl icon indicating copy to clipboard operation
AxisArrays.jl copied to clipboard

Inference failures on 0.7

Open iamed2 opened this issue 8 years ago • 2 comments
trafficstars

Indexing: Error During Test
  Test threw an exception of type ErrorException
  Expression: @inferred(D[1, 1, 1, :]) == @inferred(D[1, 1, 1, 1:1]) == @inferred(D[1, 1, 1, [1]]) == AxisArray([10], Axis{:dim_4}(Base.OneTo(1)))
  return type AxisArrays.AxisArray{Int64,1,Array{Int64,1},Tuple{AxisArrays.Axis{:dim_4,Base.OneTo{Int64}}}} does not match inferred return type AxisArrays.AxisArray{Int64,1,Array{Int64,1},_} where _

There are others but this one is the simplest (found by running AxisArrays master tests on JuliaLang master).

iamed2 avatar Jun 23 '17 02:06 iamed2

@vtjnash has given me a tentative "won't fix" but pointed me to some examples on how this issue was fixed in Base.

iamed2 avatar Jun 25 '17 13:06 iamed2

I've taken a brief look and the collector argument newaxes in _make_axes_match seems to be the problem. (And handling of such collector arguments is what likely won't be changed in the inference algorithm.) It's relatively easy to avoid using it, except for

@inline _make_axes_match(newaxes, axs::Tuple{}, nidxs::Tuple) =
    _make_axes_match((newaxes..., _nextaxistype(newaxes)(Base.OneTo(1))), (), tail(nidxs))

where it is, in fact, more than just a collector argument. Is there a way to write the generation of the singleton dimensions in a back-to-front manner, so that (only) a shrinking (instead of a growing) Tuple is passed?

EDIT: Similar situation for _default_axes and its axs argument.

martinholters avatar Jun 27 '17 08:06 martinholters