Skip to content

fixes and updates for Julia 1.9#130

Merged
mcabbott merged 8 commits into
mcabbott:masterfrom
aplavin:J19
Feb 12, 2023
Merged

fixes and updates for Julia 1.9#130
mcabbott merged 8 commits into
mcabbott:masterfrom
aplavin:J19

Conversation

@aplavin

@aplavin aplavin commented Sep 6, 2022

Copy link
Copy Markdown
Collaborator
  • add new: Base.stack for keyed arrays
  • update to match 1.9: Base.uncolon and Base.eachslice

@aplavin

aplavin commented Sep 6, 2022

Copy link
Copy Markdown
Collaborator Author

some tests still fail on nightly

@mcabbott mcabbott left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment thread src/functions.jl
@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)

Copy link
Copy Markdown
Owner

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:

@inline function eachslice(A; dims, drop=true)
    _eachslice(A, dims, drop)
end
eachrow(A::AbstractMatrix) = _eachslice(A, (1,), true)
eachcol(A::AbstractMatrix) = _eachslice(A, (2,), true)

Copy link
Copy Markdown
Collaborator Author

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 like eachslice(keyless_unname(A); dims) are cleaner. No preference between the two.

Copy link
Copy Markdown
Collaborator Author

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.

Comment thread src/functions.jl
Comment on lines +103 to 105
elseif VERSION >= v"1.1"
# This copies the implementation from Base, except with numerical_dims:
@inline function Base.eachslice(A::KeyedArray; dims)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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+.

Comment thread src/functions.jl Outdated
Comment on lines +116 to +118
@static if VERSION > v"1.9-DEV"
function Base.stack(A::KeyedArray; dims::Colon=:)
data = @invoke Base.stack(A::AbstractArray; dims)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider just depending on Compat.jl for this. Compat = "3.46, 4.2"

Here too there's an internal method we could call after dispatch, instead of @invoke:

stack(iter; dims=:) = _stack(dims, iter)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also stack.jl BTW:

function LazyStack.rewrap_like(A, a::KeyedArray)

LazyStack@0.1 is much simplified, to use Base.stack where possible. Some of the methods overloaded there don't exist anymore. No pressure though to sort it all out, that version is presently marked incompatible.

But perhaps stack needs to be qualified in the tests, to avoid some failures?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider just depending on Compat.jl for this.

Maybe, no preference on my side.

stack(iter; dims=:) = _stack(dims, iter)

As above, I find calling the actual public API functions cleaner than some internal stuff. Here keyless_unname should be a drop-in replacement for @invoke, if that's preferred.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deliberately didn't change anything regarding LazyStack.stack. Didn't use that package, and not sure about how it interplays with Base stack and everything else.

Comment thread src/functions.jl
@aplavin

aplavin commented Oct 18, 2022

Copy link
Copy Markdown
Collaborator Author

With new commits, everything should pass on both nightly and older versions.

@aplavin

aplavin commented Oct 18, 2022

Copy link
Copy Markdown
Collaborator Author

CanonicalIndexError should be fixed with JuliaLang/julia#47008

@aplavin

aplavin commented Nov 18, 2022

Copy link
Copy Markdown
Collaborator Author

Julia 1.8.3 indeed fixes that bug, and all tests now pass with no changes from my side.

Anything else I need to modify in this PR?

@aplavin

aplavin commented Nov 28, 2022

Copy link
Copy Markdown
Collaborator Author

Bump @mcabbott
This PR makes AxisKeys work with 1.9 and be consistent with that version. Would be great to merge soon, given that 1.9 doesn't seem that far away.
Further improvements, such as enabling these features on earlier julias through Compat can be done separately, if needed at all.

@aplavin

aplavin commented Dec 22, 2022

Copy link
Copy Markdown
Collaborator Author

Another bump... @mcabbott

@thorek1

thorek1 commented Jan 2, 2023

Copy link
Copy Markdown

I'm using the package in my tests and am getting ready for 1.9... but it fails due to the issues addressed in this PR

would be great to have it merged @mcabbott

@andreasnoack

Copy link
Copy Markdown
Contributor

Bump. It would be good to get this one in and released such that we can continue the testing of Julia 1.9

Comment thread src/stack.jl
Comment thread src/stack.jl
Comment thread src/stack.jl
Comment thread test/runtests.jl
Comment thread src/stack.jl
Comment thread src/functions.jl Outdated

@mcabbott mcabbott left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think stack needs more attention, but clearly I'm not getting there (and have forgotten how the interaction with LazyStack.jl worked) so merging this for now.

Comment thread src/functions.jl Outdated
@mcabbott
mcabbott merged commit 8d73d2a into mcabbott:master Feb 12, 2023
@aplavin
aplavin deleted the J19 branch February 25, 2023 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants