diff --git a/docs/src/api.md b/docs/src/api.md index c40c43312..a27cbb28c 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -53,7 +53,7 @@ Categorical Unaligned Transformed NoIndex -AutoIndex +Auto ``` Order of arrays and indices: diff --git a/src/DimensionalData.jl b/src/DimensionalData.jl index 66cada97c..4e024bbcb 100644 --- a/src/DimensionalData.jl +++ b/src/DimensionalData.jl @@ -28,7 +28,7 @@ export Sampling, Points, Intervals export Span, Regular, Irregular, AutoSpan -export IndexMode, AutoIndex, UnknownIndex, NoIndex +export IndexMode, Auto, UnknownIndex, NoIndex export Aligned, AbstractSampled, Sampled, AbstractCategorical, Categorical diff --git a/src/mode.jl b/src/mode.jl index 4f8088b22..aa451de7c 100644 --- a/src/mode.jl +++ b/src/mode.jl @@ -209,12 +209,12 @@ order(mode::NoIndex) = Ordered(Forward(), Forward(), Forward()) Automatic [`IndexMode`](@ref). Will be converted automatically to another `IndexMode` when possible. """ -struct AutoIndex{O<:Order} <: IndexMode +struct Auto{O<:Order} <: IndexMode order::O end -AutoIndex() = AutoIndex(AutoOrder()) +Auto() = Auto(AutoOrder()) -order(mode::AutoIndex) = mode.order +order(mode::Auto) = mode.order """ Supertype for [`IndexMode`](@ref) where the index is aligned with the array axes. @@ -388,9 +388,9 @@ identify(IM::Type{<:IndexMode}, dimtype::Type, index) = identify(IM(), dimtype, index) identify(mode::IndexMode, dimtype::Type, index) = mode -identify(mode::AutoIndex, dimtype::Type, index::AbstractArray) = +identify(mode::Auto, dimtype::Type, index::AbstractArray) = identify(Sampled(), dimtype, index) -identify(mode::AutoIndex, dimtype::Type, +identify(mode::Auto, dimtype::Type, index::AbstractArray{<:Union{AbstractChar,Symbol,AbstractString}}) = Categorical() identify(mode::AbstractCategorical, dimtype::Type, index) = mode diff --git a/test/dimension.jl b/test/dimension.jl index 667c153a6..1992d0a28 100644 --- a/test/dimension.jl +++ b/test/dimension.jl @@ -8,7 +8,7 @@ using DimensionalData: Forward, slicedims @test label(TestDim) == "Test dimension" @test shortname(TestDim) == "TestDim" @test val(TestDim(:test)) == :test - @test metadata(TestDim(1, AutoIndex(), "metadata")) == "metadata" + @test metadata(TestDim(1, Auto(), "metadata")) == "metadata" @test units(TestDim) == nothing @test label(TestDim) == "Test dimension" @test eltype(TestDim(1)) <: Int diff --git a/test/mode.jl b/test/mode.jl index 21a8c8902..deff87157 100644 --- a/test/mode.jl +++ b/test/mode.jl @@ -9,9 +9,9 @@ using DimensionalData: Forward, Reverse, @test identify(Sampled(sampling=Intervals()), Ti, 1:2:3) == Sampled(Ordered(), Regular(2), Intervals(Start())) - @test identify(AutoIndex(), X, 1:2:10) == + @test identify(Auto(), X, 1:2:10) == Sampled(Ordered(), Regular(2), Points()) - @test identify(AutoIndex(), X, [1, 2, 3, 4, 5]) == + @test identify(Auto(), X, [1, 2, 3, 4, 5]) == Sampled(Ordered(), Irregular(), Points()) @test identify(Sampled(), X, 1:2:10) == @@ -27,14 +27,14 @@ using DimensionalData: Forward, Reverse, @test identify(Sampled(order=Ordered(Reverse(), Forward(), Forward())), X, 10:-2:1) == Sampled(Ordered(Reverse(), Forward(), Forward()), Regular(-2), Points()) - @test identify(AutoIndex(), X, [:a, :b]) == Categorical() - @test identify(AutoIndex(), X, ["a", "b"]) == Categorical() - @test identify(AutoIndex(), X, ['a', 'b']) == Categorical() - @test identify(AutoIndex(), X, [1, 2, 3, 4]) == + @test identify(Auto(), X, [:a, :b]) == Categorical() + @test identify(Auto(), X, ["a", "b"]) == Categorical() + @test identify(Auto(), X, ['a', 'b']) == Categorical() + @test identify(Auto(), X, [1, 2, 3, 4]) == Sampled(span=Irregular()) - @test_broken identify(AutoIndex(AutoOrder()), X, [4, 3, 2, 1]) == + @test_broken identify(Auto(AutoOrder()), X, [4, 3, 2, 1]) == Sampled(Ordered(Reverse(), Forward(), Forward()), NoLocus()) - @test_broken identify(AutoIndex(AutoOrder()), X, [1, 3, 2, 9]) == + @test_broken identify(Auto(AutoOrder()), X, [1, 3, 2, 9]) == Sampled(Unordered(Forward(), NoLocus())) end