Skip to content

Commit

Permalink
Allow unzip to return JLArray
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox committed Nov 24, 2023
1 parent 87f4996 commit 1cd758f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/unzipped.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ 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
# Either is acceptable
@test unzip(jl([(missing,2), (missing,4), (missing,6)]))[2] isa Union{Base.ReinterpretArray, JLArray}
@test unzip(jl([(1,), (3,), (5,)]))[1] isa Union{Base.ReinterpretArray, JLArray}
end
end
end

0 comments on commit 1cd758f

Please sign in to comment.