From 24253ff0347ae6b7c7e0b99cd220a700d082a7dd Mon Sep 17 00:00:00 2001 From: rafaqz Date: Wed, 25 Oct 2023 01:28:49 +0200 Subject: [PATCH] bugfix --- src/utils.jl | 4 ++-- test/utils.jl | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index 652ab34bd..af16858dd 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -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...)) @@ -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) diff --git a/test/utils.jl b/test/utils.jl index 4602d9cb6..33d2b75ac 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -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