Skip to content
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

fixes and updates for Julia 1.9 #130

Merged
merged 8 commits into from
Feb 12, 2023
Merged

fixes and updates for Julia 1.9 #130

merged 8 commits into from
Feb 12, 2023

Conversation

aplavin
Copy link
Collaborator

@aplavin aplavin commented Sep 6, 2022

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

@aplavin
Copy link
Collaborator Author

aplavin commented Sep 6, 2022

some tests still fail on nightly

Copy link
Owner

@mcabbott mcabbott left a comment

Choose a reason for hiding this comment

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

Thanks!

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

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
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
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)

[email protected] 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
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
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.

src/functions.jl Show resolved Hide resolved
@aplavin
Copy link
Collaborator Author

aplavin commented Oct 18, 2022

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

@aplavin
Copy link
Collaborator Author

aplavin commented Oct 18, 2022

CanonicalIndexError should be fixed with JuliaLang/julia#47008

@aplavin
Copy link
Collaborator Author

aplavin commented Nov 18, 2022

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
Copy link
Collaborator Author

aplavin commented Nov 28, 2022

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
Copy link
Collaborator Author

aplavin commented Dec 22, 2022

Another bump... @mcabbott

@thorek1
Copy link

thorek1 commented Jan 2, 2023

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

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

src/stack.jl Show resolved Hide resolved
src/stack.jl Show resolved Hide resolved
src/stack.jl Show resolved Hide resolved
test/runtests.jl Show resolved Hide resolved
src/stack.jl Outdated Show resolved Hide resolved
src/functions.jl Outdated Show resolved Hide resolved
Copy link
Owner

@mcabbott mcabbott left a comment

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.

src/functions.jl Outdated Show resolved Hide resolved
@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