Skip to content

Commit

Permalink
allow any dims object in reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Oct 22, 2023
1 parent 6a87ffb commit 697ac81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ If no axis reversal is required the same objects will be returned, without alloc
"""
function reorder end

reorder(x, A) = reorder(x, dims(A))
reorder(x, ::Nothing) = throw(ArgumentError("object has no dimensions"))
reorder(x, p::Pair, ps::Vararg{Pair}) = reorder(x, (p, ps...))
reorder(x, ps::Tuple{Vararg{Pair}}) = reorder(x, Dimensions.pairdims(ps...))
# Reorder specific dims.
Expand Down
3 changes: 2 additions & 1 deletion test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ end

# reorder with dimension lookups
rev = reverse(da, dims=Y)
reo = reorder(rev, dims(da))
reo = reorder(rev, da)
@test rev != da
@test reo == da
@test dims(reo) == dims(da)
@test_throws ArgumentError reorder(rev, :test)
end

@testset "modify" begin
Expand Down

0 comments on commit 697ac81

Please sign in to comment.