Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ambiguity tests now they dont fail erroneously #541

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Dimensions/Dimensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ include("../LookupArrays/LookupArrays.jl")

using .LookupArrays

const LA = LookupArrays

import .LookupArrays: rebuild, order, span, sampling, locus, val, index, set, _set,
metadata, bounds, intervalbounds, units, basetypeof, unwrap, selectindices, hasselection,
shiftlocus, maybeshiftlocus, SelectorOrInterval, Interval
Expand Down
1 change: 1 addition & 0 deletions src/Dimensions/format.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ _format(span::AutoSpan, D::Type, index::Union{AbstractArray,Val}) =
_format(Irregular(), D, index)
_format(span::AutoSpan, D::Type, index::AbstractRange) = Regular(step(index))
_format(span::Regular{AutoStep}, D::Type, index::Union{AbstractArray,Val}) = _arraynosteperror()
_format(span::Regular{AutoStep}, D::Type, index::LinRange) = Regular(step(index))
_format(span::Regular{AutoStep}, D::Type, index::AbstractRange) = Regular(step(index))
_format(span::Regular, D::Type, index::Union{AbstractArray,Val}) = span
function _format(span::Regular, D::Type, index::AbstractRange)
Expand Down
25 changes: 13 additions & 12 deletions src/Dimensions/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ X, Y
```
"""
@inline dims(a1, args...) = _call_primitive(_dims, MaybeFirst(), a1, args...)
@inline dims(::Tuple{}, ::Tuple{}) = ()

@inline _dims(f, dims, query) = _remove_nothing(_sortdims(f, dims, query))

Expand Down Expand Up @@ -505,13 +506,14 @@ function comparedims end
@inline comparedims(args...; kw...) = _comparedims(_Throw, args...; kw...)
@inline comparedims(T::Type, args...; kw...) = _comparedims(T, args...; kw...)

@inline _comparedims(T::Type, ds::Dimension...; kw...) =
map(d -> _comparedims(T, first(ds), d; kw...), ds)
@inline _comparedims(T::Type, d1::Dimension, ds::Dimension...; kw...) =
map(d -> _comparedims(T, d1, d; kw...), (d1, ds...))
@inline _comparedims(T::Type, A::Tuple; kw...) = _comparedims(T, map(dims, A)...; kw...)
@inline _comparedims(T::Type, A...; kw...) = _comparedims(T, map(dims, A)...; kw...)
@inline _comparedims(T::Type, dims::Vararg{Tuple{Vararg{Dimension}}}; kw...) =
map(d -> _comparedims(T, first(dims), d; kw...), dims)

@inline _comparedims(T::Type{_Throw}; kw...) = ()
@inline _comparedims(T::Type{_Throw}, a::DimTuple, b::DimTuple; kw...) =
(_comparedims(T, first(a), first(b); kw...), _comparedims(T, tail(a), tail(b); kw...)...)
@inline _comparedims(::Type{_Throw}, a::DimTupleOrEmpty, ::Nothing; kw...) = a
Expand All @@ -529,16 +531,17 @@ function comparedims end
type && basetypeof(a) != basetypeof(b) && _dimsmismatcherror(a, b)
valtype && typeof(parent(a)) != typeof(parent(b)) && _valtypeerror(a, b)
val && parent(a) != parent(b) && _valerror(a, b)
order && order(a) != order(b) && _ordererror(a, b)
order && LA.order(a) != LA.order(b) && _ordererror(a, b)
if ignore_length_one && (Base.length(a) == 1 || Base.length(b) == 1)
return Base.length(b) == 1 ? a : b
end
length && Base.length(a) != Base.length(b) && _dimsizeerror(a, b)
return a
end

@inline _comparedims(T::Type{Bool}, ds::Dimension...; kw...) =
all(map(d -> _comparedims(T, first(ds), d; kw...), ds))
@inline _comparedims(T::Type; kw...) = true
@inline _comparedims(T::Type{Bool}, d1::Dimension, ds::Dimension...; kw...) =
all(map(d -> _comparedims(T, d1, d; kw...), ds))
@inline _comparedims(T::Type{Bool}, dims::Vararg{Tuple{Vararg{Dimension}}}; kw...) =
all(map(d -> _comparedims(T, first(dims), d; kw...), dims))
@inline _comparedims(T::Type{Bool}, a::DimTuple, b::DimTuple; kw...) =
Expand All @@ -553,16 +556,12 @@ end
@inline _comparedims(T::Type{Bool}, a::Dimension, b::AnonDim; kw...) = true
@inline _comparedims(T::Type{Bool}, a::AnonDim, b::Dimension; kw...) = true
@inline function _comparedims(::Type{Bool}, a::Dimension, b::Dimension;
type=true, lookuptype=false, valtype=false, val=false, length=true, order=false, ignore_length_one=false, warn=nothing,
type=true, valtype=false, val=false, length=true, order=false, ignore_length_one=false, warn=nothing,
)
if type && basetypeof(a) != basetypeof(b)
isnothing(warn) || _dimsmismatchwarn(a, b, warn)
return false
end
if lookuptype && basetypeof(lookup(a)) != basetypeof(lookup(b))
isnothing(warn) || _typewarn(lookup(a), lookup(b), warn)
return false
end
if valtype && typeof(parent(a)) != typeof(parent(b))
isnothing(warn) || _valtypewarn(a, b, warn)
return false
Expand Down Expand Up @@ -726,21 +725,23 @@ _valtypemsg(a, b) = "Lookup for $(basetypeof(a)) of $(lookup(a)) and $(lookup(b)
_extradimsmsg(extradims) = "$(map(basetypeof, extradims)) dims were not found in object."
_extradimsmsg(::Tuple{}) = "Some dims were not found in object."
_metadatamsg(a, b) = "Metadata $(metadata(a)) and $(metadata(b)) do not match."
_dimordermsg(a, b) = "Lookups do not all have the same order: $(order(a)), $(order(b))."
_ordermsg(a, b) = "Lookups do not all have the same order: $(order(a)), $(order(b))."
_typemsg(a, b) = "Lookups do not all have the same type: $(order(a)), $(order(b))."

# Warning: @noinline to avoid allocations when it isn't used
@noinline _dimsmismatchwarn(a, b, msg="") = @warn _dimsmismatchmsg(a, b) * msg
@noinline _valwarn(a, b, msg="") = @warn _valmsg(a, b) * msg
@noinline _dimsizewarn(a, b, msg="") = @warn _dimsizemsg(a, b) * msg
@noinline _valtypewarn(a, b, msg="") = @warn _valtypemsg(a, b) * msg
@noinline _extradimswarn(dims, msg="") = @warn _extradimsmsg(dims) * msg
@noinline _orderwarn(a, b, msg="") = @warn _ordermsg(a, b) * msg

# Error
@noinline _dimsmismatcherror(a, b) = throw(DimensionMismatch(_dimsmismatchmsg(a, b)))
@noinline _dimordererror(a, b) = throw(DimensionMismatch(_dimsizemsg(a, b)))
@noinline _dimsizeerror(a, b) = throw(DimensionMismatch(_dimsizemsg(a, b)))
@noinline _valtypeerror(a, b) = throw(DimensionMismatch(_valtypemsg(a, b)))
@noinline _valerror(a, b) = throw(DimensionMismatch(_valmsg(a, b)))
@noinline _ordererror(a, b) = throw(DimensionMismatch(_ordermsg(a, b)))
@noinline _metadataerror(a, b) = throw(DimensionMismatch(_metadatamsg(a, b)))
@noinline _extradimserror(args...) = throw(ArgumentError(_extradimsmsg(args)))
@noinline _dimsnotdefinederror() = throw(ArgumentError("Object does not define a `dims` method"))
6 changes: 3 additions & 3 deletions src/LookupArrays/selector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,9 @@ function select_unalligned_indices(lookups::LookupArrayTuple, sel::Tuple{Selecto
throw(ArgumentError("only `Near`, `At` or `Contains` selectors currently work on `Unalligned` lookups"))
end

_transform2int(lookup, ::Near, x) = min(max(round(Int, x), firstindex(lookup)), lastindex(lookup))
_transform2int(lookup, ::Contains, x) = round(Int, x)
_transform2int(lookup, sel::At, x) = _transform2int(sel, x, atol(sel))
_transform2int(lookup::AbstractArray, ::Near, x) = min(max(round(Int, x), firstindex(lookup)), lastindex(lookup))
_transform2int(lookup::AbstractArray, ::Contains, x) = round(Int, x)
_transform2int(lookup::AbstractArray, sel::At, x) = _transform2int(sel, x, atol(sel))
_transform2int(::At, x, atol::Nothing) = convert(Int, x)
function _transform2int(::At, x, atol)
i = round(Int, x)
Expand Down
2 changes: 2 additions & 0 deletions src/LookupArrays/set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ _set(lookup::LookupArray, newlookup::NoLookup) = newlookup
# Set the index
_set(lookup::LookupArray, index::Val) = rebuild(lookup; data=index)
_set(lookup::LookupArray, index::Colon) = lookup
_set(lookup::LookupArray, index::AutoLookup) = lookup
_set(lookup::LookupArray, index::AbstractArray) = rebuild(lookup; data=index)

_set(lookup::LookupArray, index::AutoIndex) = lookup
_set(lookup::LookupArray, index::AbstractRange) =
rebuild(lookup; data=_set(parent(lookup), index), order=orderof(index))
Expand Down
43 changes: 40 additions & 3 deletions src/array/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ function Base.NamedTuple(A1::AbstractDimArray, As::AbstractDimArray...)
end

# undef constructor for all AbstractDimArray
(::Type{A})(x::UndefInitializer, dims::Dimension...; kw...) where {A<:AbstractDimArray} = A(x, dims; kw...)
(::Type{A})(x::UndefInitializer, dims::Dimension...; kw...) where {A<:AbstractDimArray{<:Any}} = A(x, dims; kw...)
function (::Type{A})(x::UndefInitializer, dims::DimTuple; kw...) where {A<:AbstractDimArray{T}} where T
basetypeof(A)(Array{T}(undef, size(dims)), dims; kw...)
end
function (::Type{A})(x::UndefInitializer, dims::Tuple{}; kw...) where {A<:AbstractDimArray{T}} where T
basetypeof(A)(Array{T}(undef, ()), dims; kw...)
end

# Dummy `read` methods that does nothing.
# This can be used to actually read `AbstractDimArray` subtypes that dont hold in-memory Arrays.
Expand Down Expand Up @@ -251,7 +254,34 @@ for (d, s) in ((:AbstractDimArray, :AbstractDimArray),
copyto!(_maybeunwrap(dst), Rdst, _maybeunwrap(src), Rsrc)
end
end
Base.copy!(dst::SparseArrays.SparseVector, src::AbstractDimArray{T,1}) where T = copy!(dst, parent(src))
# Ambiguity
Base.copyto!(dst::AbstractDimArray{T,2}, src::SparseArrays.CHOLMOD.Dense{T}) where T<:Union{Float64,ComplexF64} =
copyto!(parent(dst), src)
Base.copyto!(dst::AbstractDimArray{T}, src::SparseArrays.CHOLMOD.Dense{T}) where T<:Union{Float64,ComplexF64} =
copyto!(parent(dst), src)
Base.copyto!(dst::DimensionalData.AbstractDimArray, src::SparseArrays.CHOLMOD.Dense) =
copyto!(parent(dst), src)
Base.copyto!(dst::AbstractDimArray{T,2} where T, src::SparseArrays.AbstractSparseMatrixCSC) =
copyto!(parent(dst), src)
Base.copyto!(dst::AbstractDimArray{T,2} where T, src::LinearAlgebra.AbstractQ) =
copyto!(parent(dst), src)
Base.copyto!(dst::SparseArrays.AbstractCompressedVector, src::AbstractDimArray{T, 1} where T) =
copyto!(dst, parent(src))
Base.copyto!(dst::PermutedDimsArray, src::AbstractDimArray) =
copyto!(dst, parent(src))
function Base.copyto!(
dst::AbstractDimArray{<:Any,2},
dst_i::CartesianIndices{2, R} where R<:Tuple{OrdinalRange{Int64, Int64}, OrdinalRange{Int64, Int64}},
src::SparseArrays.AbstractSparseMatrixCSC{<:Any},
src_i::CartesianIndices{2, R} where R<:Tuple{OrdinalRange{Int64, Int64}, OrdinalRange{Int64, Int64}}
)
copyto!(parent(dst), dst_i, src, src_i)
end

Base.copy!(dst::SparseArrays.SparseVector, src::AbstractDimArray{T,1}) where T =
copy!(dst, parent(src))
Base.copy!(dst::SparseArrays.AbstractCompressedVector{T}, src::AbstractDimArray{T, 1}) where T =
copy!(dst, parent(src))

ArrayInterface.parent_type(::Type{<:AbstractDimArray{T,N,D,A}}) where {T,N,D,A} = A

Expand Down Expand Up @@ -550,9 +580,16 @@ function Base.rand(r::AbstractRNG, x, dims::DimTuple; kw...)
C = dimconstructor(dims)
C(rand(r, x, _dimlength(dims)), _maybestripval(dims); kw...)
end
function Base.rand(r::AbstractRNG, d1::Dimension, dims::Dimension...; kw...)
rand(r, (d1, dims...); kw...)
end
function Base.rand(r::AbstractRNG, ::Type{T}, d1::Dimension, dims::Dimension...; kw...) where T
rand(r, T, (d1, dims...); kw...)
end
function Base.rand(r::AbstractRNG, dims::DimTuple; kw...)
C = dimconstructor(dims)
C(rand(r, _dimlength(dims)), _maybestripval(dims); kw...)
end
function Base.rand(r::AbstractRNG, ::Type{T}, dims::DimTuple; kw...) where T
C = dimconstructor(dims)
C(rand(r, T, _dimlength(dims)), _maybestripval(dims); kw...)
Expand Down Expand Up @@ -692,4 +729,4 @@ _unmergedims(all_dims, dim_pairs::Pair...) = _cat_tuples(replace(all_dims, dim_p

_cat_tuples(tuples...) = mapreduce(_astuple, (x, y) -> (x..., y...), tuples)

_filter_dims(alldims, dims) = filter(dim -> hasdim(alldims, dim), dims)
_filter_dims(alldims, dims) = filter(dim -> hasdim(alldims, dim), dims)
5 changes: 4 additions & 1 deletion src/array/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,7 @@ end
setindex!(parent(A), x, i1, I...)

# For @views macro to work with keywords
Base.maybeview(A::AbstractDimArray, args...; kw...) = view(A, args...; kw...)
Base.maybeview(A::AbstractDimArray, args...; kw...) =
view(A, args...; kw...)
Base.maybeview(A::AbstractDimArray, args::Vararg{Union{Number,Base.AbstractCartesianIndex}}; kw...) =
view(A, args...; kw...)
1 change: 1 addition & 0 deletions src/array/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ for (a, b) in (
@eval Base.:*(A::$a, B::$b) = _rebuildmul(A, B)
end


Base.:*(A::AbstractDimVector, B::Adjoint{T,<:AbstractRotation}) where T = _rebuildmul(A, B)
Base.:*(A::Adjoint{T,<:AbstractRotation}, B::AbstractDimMatrix) where T = _rebuildmul(A, B)
Base.:*(A::Transpose{<:Any,<:AbstractMatrix{T}}, B::AbstractDimArray{S,1}) where {T,S} = _rebuildmul(A, B)
Expand Down
15 changes: 10 additions & 5 deletions src/array/methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ end
function Base._mapreduce_dim(f, op, nt, A::AbstractDimArray, dims)
rebuild(A, Base._mapreduce_dim(f, op, nt, parent(A), dimnum(A, dims)), reducedims(A, dims))
end
function Base._mapreduce_dim(f, op, nt, A::AbstractDimArray, dims::Colon)
rebuild(A, Base._mapreduce_dim(f, op, nt, parent(A), dimnum(A, dims)), reducedims(A, dims))
end

@static if VERSION >= v"1.6"
function Base._mapreduce_dim(f, op, nt::Base._InitialValue, A::AbstractDimArray, dims)
rebuild(A, Base._mapreduce_dim(f, op, nt, parent(A), dimnum(A, dims)), reducedims(A, dims))
Expand Down Expand Up @@ -344,10 +348,10 @@ check_cat_lookups(dims::Dimension...) =

# LookupArrays may need adjustment for `cat`
_check_cat_lookups(D, lookups::LookupArray...) = _check_cat_lookup_order(D, lookups...)
_check_cat_lookups(D, lookups::NoLookup...) = true
function _check_cat_lookups(D, lookups::AbstractSampled...)
_check_cat_lookup_order(D, lookups...) || return false
_check_cat_lookups(D, span(first(lookups)), lookups...)
_check_cat_lookups(D, l1::NoLookup, lookups::NoLookup...) = true
function _check_cat_lookups(D, l1::AbstractSampled, lookups::AbstractSampled...)
_check_cat_lookup_order(D, l1, lookups...) || return false
_check_cat_lookups(D, span(l1), l1, lookups...)
end
function _check_cat_lookups(D, ::Regular, lookups...)
length(lookups) > 1 || return true
Expand Down Expand Up @@ -483,7 +487,7 @@ end
@noinline _cat_lookup_overlap_warn(D, x1, x2) = @warn _cat_warn_string(D, "`Ordered` lookups are misaligned at $x2 and $x1")
@noinline _cat_lookup_intersect_warn(D, intr) = @warn _cat_warn_string(D, "`Unorderd` lookups share values: $intr")

@noinline _mixed_span_error(D, S, span) = throw(DimensionMismatch(_span_string(T, span)))
@noinline _mixed_span_error(D, S, span) = throw(DimensionMismatch(_span_string(D, S, span)))
@noinline function _mixed_span_warn(D, S, span)
@warn _span_string(D, S, span)
return false
Expand Down Expand Up @@ -541,3 +545,4 @@ _reverse(dim::Dimension) = reverse(dim)
Base.reverse(dim::Dimension) = rebuild(dim, reverse(lookup(dim)))

Base.dataids(A::AbstractDimArray) = Base.dataids(parent(A))

6 changes: 5 additions & 1 deletion src/dimindices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ for f in (:getindex, :view, :dotview)
end
end

(::Type{<:AbstractDimIndices})(::Nothing; kw...) = throw(ArgumentError("Object has no `dims` method"))
(::Type{T})(::Nothing; kw...) where T<:AbstractDimIndices = throw(ArgumentError("Object has no `dims` method"))
(::Type{T})(x; kw...) where T<:AbstractDimIndices = T(dims(x); kw...)
(::Type{T})(dim::Dimension; kw...) where T<:AbstractDimIndices = T((dim,); kw...)

Expand All @@ -42,6 +42,10 @@ indices of unknown dimension.
"""
struct DimIndices{T,N,D<:Tuple{Vararg{Dimension}}} <: AbstractDimIndices{T,N}
dims::D
# Manual inner constructor for ambiguity only
function DimIndices{T,N,D}(dims::Tuple{Vararg{Dimension}}) where {T,N,D<:Tuple{Vararg{Dimension}}}
new{T,N,D}(dims)
end
end
function DimIndices(dims::D) where {D<:Tuple{Vararg{Dimension}}}
T = typeof(map(d -> rebuild(d, 1), dims))
Expand Down
22 changes: 11 additions & 11 deletions src/plotrecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct DimensionalPlot end
DimensionalPlot(), A
end

@recipe function f(::DimensionalPlot, A::AbstractArray)
@recipe function f(::DimensionalPlot, A::AbstractDimArray)
A_fwd = reorder(A, ForwardOrdered())
sertype = get(plotattributes, :seriestype, :none)::Symbol
if !(sertype in (:marginalhist,))
Expand Down Expand Up @@ -44,15 +44,15 @@ end
end
end

@recipe function f(s::SeriesLike, A::AbstractArray{T,1}) where T
@recipe function f(s::SeriesLike, A::AbstractDimArray{T,1}) where T
dim = dims(A, 1)
:xguide --> label(dim)
:yguide --> label(A)
:label --> string(name(A))
_xticks!(plotattributes, s, dim)
_withaxes(dim, A)
end
@recipe function f(s::SeriesLike, A::AbstractArray{T,2}) where T
@recipe function f(s::SeriesLike, A::AbstractDimArray{T,2}) where T
A = permutedims(A, forward_order_plot_dims(A))
ind, dep = dims(A)
:xguide --> label(ind)
Expand All @@ -64,12 +64,12 @@ end
_withaxes(ind, A)
end

@recipe function f(s::HistogramLike, A::AbstractArray{T,1}) where T
@recipe function f(s::HistogramLike, A::AbstractDimArray{T,1}) where T
dim = dims(A, 1)
:xguide --> label(A)
_withaxes(dim, A)
end
@recipe function f(s::HistogramLike, A::AbstractArray{T,2}) where T
@recipe function f(s::HistogramLike, A::AbstractDimArray{T,2}) where T
ds = reverse_order_plot_dims(A)
A = permutedims(A, ds)
ind, dep = dims(A)
Expand All @@ -79,12 +79,12 @@ end
_withaxes(ind, A)
end

@recipe function f(::ViolinLike, A::AbstractArray{T,1}) where T
@recipe function f(::ViolinLike, A::AbstractDimArray{T,1}) where T
dim = dims(A, 1)
:yguide --> label(A)
parent(A)
end
@recipe function f(s::ViolinLike, A::AbstractArray{T,2}) where T
@recipe function f(s::ViolinLike, A::AbstractDimArray{T,2}) where T
ds = reverse_order_plot_dims(A)
A = permutedims(A, ds)
dep, ind = dims(A)
Expand All @@ -95,7 +95,7 @@ end
_xticks!(plotattributes, s, ind)
parent(A)
end
@recipe function f(s::ViolinLike, A::AbstractArray{T,3}) where T
@recipe function f(s::ViolinLike, A::AbstractDimArray{T,3}) where T
ds = reverse_order_plot_dims(A)
A = permutedims(A, ds)
dep2, dep1, ind = dims(A)
Expand All @@ -107,14 +107,14 @@ end
parent(A)
end

@recipe function f(s::HeatMapLike, A::AbstractArray{T,1}) where T
@recipe function f(s::HeatMapLike, A::AbstractDimArray{T,1}) where T
dim = dims(A, 1)
:xguide --> label(dim)
:yguide --> label(A)
_xticks!(plotattributes, s, dim)
parent(A)
end
@recipe function f(s::HeatMapLike, A::AbstractArray{T,2}) where T
@recipe function f(s::HeatMapLike, A::AbstractDimArray{T,2}) where T
ds = reverse_order_plot_dims(A)
A = permutedims(A, ds)
y, x = dims(A)
Expand All @@ -126,7 +126,7 @@ end
_yticks!(plotattributes, s, y)
_withaxes(x, y, A)
end
@recipe function f(x::DimPlotMode, A::AbstractArray{T,N}) where {T,N}
@recipe function f(x::DimPlotMode, A::AbstractDimArray{T,N}) where {T,N}
throw(ArgumentError("$(x.seriestype) not implemented in $N dimensions"))
end

Expand Down
6 changes: 3 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ _reorder(x, orderdims::Tuple{}) = x

reorder(x, orderdim::Dimension) = _reorder(val(orderdim), x, dims(x, orderdim))

_reorder(neworder::Order, x, dim::DimOrDimType) = _reorder(basetypeof(neworder), x, dim)
_reorder(neworder::Order, x, dim::Dimension) = _reorder(basetypeof(neworder), x, dim)
# Reverse the dimension index
_reorder(::Type{O}, x, dim::DimOrDimType) where O<:Ordered =
_reorder(::Type{O}, x, dim::Dimension) where O<:Ordered =
order(dim) isa O ? x : reverse(x; dims=dim)
_reorder(ot::Type{Unordered}, x, dim::DimOrDimType) = x
_reorder(ot::Type{Unordered}, x, dim::Dimension) = x

"""
modify(f, A::AbstractDimArray) => AbstractDimArray
Expand Down
3 changes: 1 addition & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using DimensionalData, Aqua, SafeTestsets

if VERSION >= v"1.5.0"
# This is catching some unambiguous constructors for T<:Metadata.
# Aqua.test_ambiguities([DimensionalData, Base, Core])
Aqua.test_ambiguities([DimensionalData, Base, Core])
Aqua.test_unbound_args(DimensionalData)
Aqua.test_undefined_exports(DimensionalData)
Aqua.test_project_extras(DimensionalData)
Expand Down
Loading