-
Notifications
You must be signed in to change notification settings - Fork 29
fixes and updates for Julia 1.9 #130
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
Changes from all commits
522c05b
d58f0cb
47cc2d6
5f4ea56
6830d6a
bff1056
20f24ba
beb790e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,7 +94,13 @@ function Base.permutedims(A::KeyedArray, perm) | |
KeyedArray(data, new_keys)#, copy(A.meta)) | ||
end | ||
|
||
if VERSION >= v"1.1" | ||
@static if VERSION > v"1.9-DEV" | ||
function Base.eachslice(A::KeyedArray; dims) | ||
dims_ix = AxisKeys.dim(A, dims) |> Tuple | ||
data = @invoke eachslice(A::AbstractArray; dims=dims_ix) | ||
return KeyedArray(NamedDimsArray(data, map(d -> dimnames(A, d), dims_ix)), map(d -> axiskeys(A, d), dims_ix)) | ||
end | ||
elseif VERSION >= v"1.1" | ||
# This copies the implementation from Base, except with numerical_dims: | ||
@inline function Base.eachslice(A::KeyedArray; dims) | ||
Comment on lines
+103
to
105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JuliaLang/Compat.jl#663 still isn't merged, so it makes sense to keep this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if I follow. How is Compat related here? This PR only makes changes on 1.9+. |
||
numerical_dims = NamedDims.dim(A, dims) | ||
|
@@ -107,6 +113,19 @@ if VERSION >= v"1.1" | |
end | ||
end | ||
|
||
@static if VERSION > v"1.9-DEV" | ||
# TODO: this will ERROR if given dims, instead of falling back to Base | ||
# TODO: ideally it would dispatch on the element type, for e.g. a generator of KeyedArrays | ||
function Base.stack(A::KeyedArray; dims::Colon=:) | ||
data = @invoke stack(A::AbstractArray; dims) | ||
if !allequal(named_axiskeys(a) for a in A) | ||
throw(DimensionMismatch("stack expects uniform axiskeys for all arrays")) | ||
end | ||
akeys = (; named_axiskeys(first(A))..., named_axiskeys(A)...) | ||
aplavin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
KeyedArray(data; akeys...) | ||
end | ||
end | ||
|
||
function Base.mapslices(f, A::KeyedArray; dims) | ||
numerical_dims = NamedDims.dim(A, dims) | ||
data = mapslices(f, parent(A); dims=numerical_dims) | ||
|
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.
Rather than
@invoke
, could this just call the next function down? There seems to be an_eachslice
which is always called, like so: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.
Instead of depending on internals, I think either the current
@invoke
solution or something likeeachslice(keyless_unname(A); dims)
are cleaner. No preference between the two.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.
The
keyless_unname
way may require some processing for inner arrays though.