-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
EachRow/EachCol types (see #32310) #663
base: master
Are you sure you want to change the base?
Conversation
@@ -1903,6 +1903,17 @@ if v"0.7.0" <= VERSION < v"1.3.0-alpha.8" | |||
Base.mod(i::Integer, r::AbstractUnitRange{<:Integer}) = mod(i-first(r), length(r)) + first(r) | |||
end | |||
|
|||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.A to 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 |
1.9alpha is out. What's the plan here? |
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