Skip to content

Commit

Permalink
anon is even better
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Apr 2, 2020
1 parent 74c13ed commit f94f92f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Categorical
Unaligned
Transformed
NoIndex
AutoIndex
Auto
```

Order of arrays and indices:
Expand Down
2 changes: 1 addition & 1 deletion src/DimensionalData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/mode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/dimension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions test/mode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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) ==
Expand All @@ -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
Expand Down

0 comments on commit f94f92f

Please sign in to comment.