Skip to content

Commit ead8013

Browse files
committed
Deprecate fastindices. Closes #80
1 parent afa411c commit ead8013

File tree

2 files changed

+17
-49
lines changed

2 files changed

+17
-49
lines changed

src/ComponentArrays.jl

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,32 @@ const FlatOrColonIdx = Union{FlatIdx, Colon}
99

1010

1111
include("utils.jl")
12+
export fastindices
13+
1214
include("lazyarray.jl")
15+
1316
include("axis.jl")
17+
export AbstractAxis, Axis, PartitionedAxis, ShapedAxis, ViewAxis, FlatAxis
18+
1419
include("componentindex.jl")
20+
1521
include("componentarray.jl")
22+
export ComponentArray, ComponentVector, ComponentMatrix, getaxes, getdata, valkeys
23+
1624
include("set_get.jl")
25+
1726
include("similar_convert_copy.jl")
27+
1828
include("broadcasting.jl")
29+
1930
include("math.jl")
31+
2032
include("show.jl")
33+
2134
include("plot_utils.jl")
22-
# include(joinpath("if_required", "chainrulescore.jl"))
35+
export labels, label2index
36+
2337

24-
# If using for differential equations, the Array(sol) overload in RecursiveArrayTools will
25-
# concatenate the ComponentVectors while preserving their ComponentArrayness
2638
required(filename) = include(joinpath("if_required", filename))
2739

2840
function __init__()
@@ -33,16 +45,8 @@ function __init__()
3345
@require SciMLBase="0bca4576-84f4-4d90-8ffe-ffa030f20462" required("scimlbase.jl")
3446
@require RecursiveArrayTools="731186ca-8d62-57ce-b412-fbd966d074cd" required("recursivearraytools.jl")
3547
@require StaticArrays="90137ffa-7385-5640-81b9-e52037218182" required("staticarrays.jl")
36-
# @require Zygote="e88e6eb3-aa80-5325-afca-941959d7151f" required("zygote.jl")
3748
@require ChainRulesCore="d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" required("chainrulescore.jl")
3849
@require ReverseDiff="37e2e3b7-166d-5795-8a7a-e32c996b4267" required("reversediff.jl")
3950
end
4051

41-
42-
export AbstractAxis, Axis, PartitionedAxis, ShapedAxis, ViewAxis, FlatAxis
43-
44-
export ComponentArray, ComponentVector, ComponentMatrix
45-
46-
export getdata, getaxes, fastindices, labels, label2index, valkeys
47-
4852
end

src/utils.jl

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,5 @@
1-
"""
2-
fastindices(i...)
3-
4-
Wrap ```ComponentArray``` symbolic indices in ```Val```s for type-stable indexing.
5-
6-
# Examples
7-
```julia-repl
8-
julia> using ComponentArrays
9-
10-
julia> ca = ComponentArray(a=1, b=[2, 1, 4], c=(a=2, b=[1, 2]))
11-
ComponentVector{Int64}(a = 1, b = [2, 1, 4], c = (a = 2, b = [1, 2]))
12-
13-
julia> ca2 = ca .* ca'
14-
7×7 ComponentMatrix{Int64} with axes Axis(a = 1, b = 2:4, c = ViewAxis(5:7, Axis(a = 1, b = 2:3))) × Axis(a = 1, b = 2:4, c = ViewAxis(5:7, Axis(a = 1, b = 2:3)))
15-
1 2 1 4 2 1 2
16-
2 4 2 8 4 2 4
17-
1 2 1 4 2 1 2
18-
4 8 4 16 8 4 8
19-
2 4 2 8 4 2 4
20-
1 2 1 4 2 1 2
21-
2 4 2 8 4 2 4
22-
23-
julia> _a, _b, _c = fastindices(:a, :b, :c)
24-
(Val{:a}(), Val{:b}(), Val{:c}())
25-
26-
julia> ca2[_c, _c]
27-
3×3 ComponentMatrix{Int64,SubArray...} with axes Axis(a = 1, b = 2:3) × Axis(a = 1, b = 2:3)
28-
4 2 4
29-
2 1 2
30-
4 2 4
31-
32-
julia> ca2[_c, _c] == ca2[:c, :c]
33-
true
34-
```
35-
"""
36-
fastindices(i...) = toval.(i)
37-
fastindices(i::Tuple) = toval.(i)
38-
1+
@deprecate fastindices(i::Tuple) Val.(i)
2+
@deprecate fastindices(i...) Val.((i...,))
393

404
# Make a Val if input isn't already one
415
toval(x::Val) = x

0 commit comments

Comments
 (0)