Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Oct 24, 2023
1 parent 18176cd commit 24253ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ true
"""
function reorder end

reorder(x, A) = reorder(x, dims(A))
reorder(x, A::Union{AbstractDimArray,AbstractDimStack,AbstractDimIndices}) = 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...))
Expand All @@ -43,7 +43,7 @@ reorder(dim::Dimension, ot::Type{<:Order}) =
_reorder(x, orderdims::DimTuple) = _reorder(reorder(x, orderdims[1]), tail(orderdims))
_reorder(x, orderdims::Tuple{}) = x

reorder(x, orderdim::Dimension{<:Order}) = _reorder(val(orderdim), x, dims(x, orderdim))
reorder(x, orderdim::Dimension) = _reorder(val(orderdim), x, dims(x, orderdim))
reorder(x, orderdim::Dimension{<:LookupArray}) = _reorder(order(orderdim), x, dims(x, orderdim))

_reorder(neworder::Order, x, dim::Dimension) = _reorder(basetypeof(neworder), x, dim)
Expand Down
7 changes: 6 additions & 1 deletion test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ end
@test rev != da
@test reo == da
@test dims(reo) == dims(da)
@test_throws ArgumentError reorder(rev, :test)
@test_throws MethodError reorder(rev, :test)
rev_s = reverse(s, dims=Y)
reo_s = reorder(rev_s, da)
@test rev_s != s
@test reo_s == s
@test dims(reo_s) == dims(s)
end

@testset "modify" begin
Expand Down

0 comments on commit 24253ff

Please sign in to comment.