EachRow/EachCol types (see #32310)#663
Conversation
|
|
||
| # https://github.com/JuliaLang/julia/pull/32310 | ||
| if v"0.7.0" <= VERSION | ||
| const EachRow{A,I} = Union{Base.Generator{I,(typeof(eachrow(ones(Int32,2,2)).f).name.wrapper){A}}, Base.Generator{I,(typeof(eachrow(ones(Int32,2,2)).f).name.wrapper){A}} |
There was a problem hiding this comment.
| const EachRow{A,I} = Union{Base.Generator{I,(typeof(eachrow(ones(Int32,2,2)).f).name.wrapper){A}}, Base.Generator{I,(typeof(eachrow(ones(Int32,2,2)).f).name.wrapper){A}} | |
| const EachRow{A,I} = Union{Base.Generator{I,(typeof(eachrow(ones(Int32,2,2)).f).name.wrapper){A}}, Base.Generator{I,(typeof(eachrow(ones(Int32,2,2)).f).name.wrapper){A}}} |
|
Could we also define |
|
We could also add const EachSlice{A,I} = Base.Generator{I,<:(typeof(eachslice(ones(Int32,2,2), dims = 1).f).name.wrapper){A}}
Base.parent(x::EachSlice) = x.f.Ato add support for "legacy" julia> parent(eachslice(rand(3,4,5,6), dims = 3))
3×4×5×6 Array{Float64, 4}:
#... |
|
With JuliaLang/julia#32310 finally merged, this could now be picked up again if there is still interest. |
|
I think we should definitely do this. Ideally with |
|
Adding Probably the best would be to implement both approaches. The former is useful for packages that want to use a special method when users call |
Ah - I don't want to add it to have eachrow and eachcol as subtypes - that's not possible, I agree. But I think it's important to add it in Compat so that packages like ArraysOfArrays.jl and JuliennedArrays.jl can make their types subtypes of AbstractSlices while still supporting Julia LTS. And so we can do something like in ArrayInterfaceCore (prototyping this here). That will then allow code that can take advantage of slices array to dispatch on For that to work, we need an |
|
Bump - is there support for adding this to Compat? |
Obviously still needs JuliaLang/julia#32310 to be merged, but this is just to show we can monkey-patch the aliases to support older versions of Julia.
cc: @nalimilan