Skip to content

Commit

Permalink
Allow unzip to return JLArray (#759)
Browse files Browse the repository at this point in the history
* Allow unzip to return JLArray

* style

* style

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* extend comment

Co-authored-by: Michael Abbott <[email protected]>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Michael Abbott <[email protected]>
  • Loading branch information
3 people authored Dec 1, 2023
1 parent 87f4996 commit 40b9058
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/unzipped.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ 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/package versions, may get ReinterpretArray or JLArray
# Either is acceptable
@test isa(
unzip(jl([(missing, 2), (missing, 4), (missing, 6)]))[2],
Union{Base.ReinterpretArray,JLArray},
)
end
end
end

0 comments on commit 40b9058

Please sign in to comment.