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

Allow unzip to return JLArray #759

Merged
merged 4 commits into from
Dec 1, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions test/unzipped.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,18 @@ using ChainRules: unzip_broadcast, unzip #, unzip_map
# TODO invent some tests of this rrule's pullback function

@test unzip(jl([(1,2), (3,4), (5,6)])) == (jl([1, 3, 5]), jl([2, 4, 6]))

@test unzip(jl([(missing,2), (missing,4), (missing,6)]))[2] == jl([2, 4, 6])
@test unzip(jl([(missing,2), (missing,4), (missing,6)]))[2] isa Base.ReinterpretArray

@test unzip(jl([(1,), (3,), (5,)]))[1] == jl([1, 3, 5])
@test unzip(jl([(1,), (3,), (5,)]))[1] isa Base.ReinterpretArray

# depending on Julia version may get ReinterpretArray or may get JLArray
oxinabox marked this conversation as resolved.
Show resolved Hide resolved
# Either is acceptable
@test isa(
unzip(jl([(missing,2), (missing,4), (missing,6)]))[2],
Union{Base.ReinterpretArray, JLArray}
)
@test isa(
unzip(jl([(1,), (3,), (5,)]))[1],
Union{Base.ReinterpretArray, JLArray}
oxinabox marked this conversation as resolved.
Show resolved Hide resolved
)
end
end
end
Loading