Skip to content

Commit 1f373cf

Browse files
committed
Axes and broadcasting overhaul
1 parent 37e3e4d commit 1f373cf

File tree

11 files changed

+278
-110
lines changed

11 files changed

+278
-110
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ComponentArrays"
22
uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
33
authors = ["Jonnie Diegelman <47193959+jonniedie@users.noreply.github.com>"]
4-
version = "0.10.5"
4+
version = "0.11.0"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/ComponentArrays.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ include("lazyarray.jl")
1616
include("axis.jl")
1717
export AbstractAxis, Axis, PartitionedAxis, ShapedAxis, ViewAxis, FlatAxis
1818

19-
include("componentindex.jl")
20-
export KeepIndex
21-
2219
include("componentarray.jl")
2320
export ComponentArray, ComponentVector, ComponentMatrix, getaxes, getdata, valkeys
2421

22+
include("componentindex.jl")
23+
export KeepIndex
24+
2525
include("array_interface.jl")
2626
# Base methods: parent, size, elsize, axes, reinterpret, hcat, vcat, permutedims, IndexStyle, to_indices, to_index, getindex, setindex!, view, pointer, unsafe_convert, strides, stride
2727
# ArrayInterface methods: strides, size, lu_instance, parent_type

src/array_interface.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ ArrayInterface.size(A::ComponentArray) = ArrayInterface.size(parent(A))
55

66
Base.elsize(x::Type{<:ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = Base.elsize(A)
77

8-
Base.axes(x::ComponentArray) = axes(getdata(x))
8+
# Base.axes(x::ComponentArray) = axes(getdata(x))
9+
Base.axes(x::ComponentArray) = CombinedAxis.(getaxes(x), axes(getdata(x)))
910

1011
Base.reinterpret(::Type{T}, x::ComponentArray, args...) where T = ComponentArray(reinterpret(T, getdata(x), args...), getaxes(x))
1112

src/axis.jl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ const NotShapedOrPartitionedAxis = Union{Axis{IdxMap}, FlatAxis, NullAxis} where
140140

141141
Base.merge(axs::Axis...) = Axis(merge(indexmap.(axs)...))
142142

143+
Base.firstindex(ax::AbstractAxis) = first(viewindex(first(indexmap(ax))))
143144
Base.lastindex(ax::AbstractAxis) = last(viewindex(last(indexmap(ax))))
144145

145146
Base.keys(ax::AbstractAxis) = keys(indexmap(ax))
@@ -154,3 +155,41 @@ reindex(ax::ViewAxis, offset) = ViewAxis(viewindex(ax) .+ offset, indexmap(ax))
154155
@inline Base.getindex(ax::AbstractAxis, ::Colon) = ComponentIndex(:, ax)
155156
@inline Base.getindex(::AbstractAxis{IdxMap}, s::Symbol) where IdxMap =
156157
ComponentIndex(getproperty(IdxMap, s))
158+
159+
Base.iterate(ax::AbstractAxis, state=1) = state > lastindex(ax) ? nothing : (ax[state], state+1)
160+
161+
Base.length(ax::AbstractAxis) = lastindex(ax) - firstindex(ax) + 1
162+
163+
Base.UnitRange(ax::AbstractAxis) = firstindex(ax):lastindex(ax)
164+
Base.UnitRange{T}(ax::AbstractAxis) where {T} = T(firstindex(ax)):T(lastindex(ax))
165+
166+
167+
struct CombinedAxis{C,A} <: AbstractUnitRange{Int}
168+
component_axis::C
169+
array_axis::A
170+
end
171+
172+
const CombinedOrRegularAxis = Union{Integer, AbstractUnitRange, CombinedAxis}
173+
174+
_component_axis(ax::CombinedAxis) = ax.component_axis
175+
_component_axis(ax) = FlatAxis()
176+
177+
_array_axis(ax::CombinedAxis) = ax.array_axis
178+
_array_axis(ax) = ax
179+
180+
Base.first(ax::CombinedAxis) = first(_array_axis(ax))
181+
182+
Base.last(ax::CombinedAxis) = last(_array_axis(ax))
183+
184+
Base.firstindex(ax::CombinedAxis) = firstindex(_array_axis(ax))
185+
186+
Base.lastindex(ax::CombinedAxis) = lastindex(_array_axis(ax))
187+
188+
Base.getindex(ax::CombinedAxis, i::Integer) = _array_axis(ax)[i]
189+
Base.getindex(ax::CombinedAxis, i::AbstractArray) = _array_axis(ax)[i]
190+
191+
Base.length(ax::CombinedAxis) = lastindex(ax) - firstindex(ax) + 1
192+
193+
# Base.iterate(ax::CombinedAxis, state=1) = state>lastindex(ax) ? nothing : (ax[state], state+1)
194+
195+
Base.CartesianIndices(ax::Tuple{Vararg{CombinedAxis}}) = CartesianIndices(_array_axis.(ax))

src/broadcasting.jl

Lines changed: 77 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,63 +10,89 @@ function CAStyle(::InnerStyle, ax::Axes, ::Val{N}) where {InnerStyle, Axes, N}
1010
end
1111

1212

13-
function Base.BroadcastStyle(::Type{<:ComponentArray{T, N, A, Axes}}) where {T, A, N, Axes}
14-
return CAStyle(Base.BroadcastStyle(A), getaxes(Axes), ndims(A))
15-
end
16-
function Base.BroadcastStyle(AA::Type{<:Adjoint{T, <:ComponentArray{T, N, A, Axes}}}) where {T, N, A, Axes}
17-
return CAStyle(Base.BroadcastStyle(Adjoint{T,A}), getaxes(AA), ndims(AA))
18-
end
19-
function Base.BroadcastStyle(AA::Type{<:Transpose{T, <:ComponentArray{T, N, A, Axes}}}) where {T, N, A, Axes}
20-
return CAStyle(Base.BroadcastStyle(Transpose{T,A}), getaxes(AA), ndims(AA))
21-
end
22-
23-
function Base.BroadcastStyle(::CAStyle{InnerStyle, Axes, N}, bc::BC.Broadcasted) where {InnerStyle, Axes, N}
24-
return CAStyle(Base.BroadcastStyle(InnerStyle(), bc), Axes, N)
25-
end
13+
# function Base.BroadcastStyle(::Type{<:ComponentArray{T, N, A, Axes}}) where {T, A, N, Axes}
14+
# return CAStyle(Base.BroadcastStyle(A), getaxes(Axes), ndims(A))
15+
# end
16+
# function Base.BroadcastStyle(AA::Type{<:Adjoint{T, <:ComponentArray{T, N, A, Axes}}}) where {T, N, A, Axes}
17+
# return CAStyle(Base.BroadcastStyle(Adjoint{T,A}), getaxes(AA), ndims(AA))
18+
# end
19+
# function Base.BroadcastStyle(AA::Type{<:Transpose{T, <:ComponentArray{T, N, A, Axes}}}) where {T, N, A, Axes}
20+
# return CAStyle(Base.BroadcastStyle(Transpose{T,A}), getaxes(AA), ndims(AA))
21+
# end
2622

23+
# function Base.BroadcastStyle(::CAStyle{InnerStyle, Axes, N}, bc::BC.Broadcasted) where {InnerStyle, Axes, N}
24+
# return CAStyle(Base.BroadcastStyle(InnerStyle(), bc), Axes, N)
25+
# end
2726

28-
function BC.BroadcastStyle(::CAStyle{<:In1, <:Ax1, <:N1}, ::CAStyle{<:In2, <:Ax2, <:N2}) where {In1, Ax1, N1, In2, Ax2, N2}
29-
ax, N = fill_flat(Ax1, Ax2, N1, N2)
30-
inner_style = BC.BroadcastStyle(In1(), In2())
31-
if inner_style isa BC.Unknown
32-
inner_style = BC.DefaultArrayStyle{N}()
33-
end
34-
return CAStyle(inner_style, ax, N)
35-
end
36-
function BC.BroadcastStyle(::CAStyle{In, Ax, N1}, ::Style) where Style<:BC.DefaultArrayStyle{N2} where {In, Ax, N1, N2}
37-
N = max(N1, N2)
38-
ax = fill_flat(Ax, max(N1, N2))
39-
inner_style = BC.BroadcastStyle(In(), Style())
40-
return CAStyle(inner_style, ax, N)
41-
end
42-
function BC.BroadcastStyle(CAS::CAStyle{In, Ax, N1}, ::BC.DefaultArrayStyle{0}) where {In, Ax, N1}
43-
return CAS
44-
end
45-
function BC.BroadcastStyle(CAS::CAStyle{In, Ax, N}, ::BC.DefaultArrayStyle{N}) where {In, Ax, N}
46-
return CAS
47-
end
48-
function BC.BroadcastStyle(::CAStyle{In, Ax, N1}, ::Style) where Style<:BC.AbstractArrayStyle{N2} where {In, Ax, N1, N2}
49-
N = max(N1, N2)
50-
ax = fill_flat(Ax, max(N1, N2))
51-
inner_style = BC.BroadcastStyle(In(), Style())
52-
return CAStyle(inner_style, ax, N)
53-
end
27+
Base.BroadcastStyle(::Type{<:ComponentArray{T, N, A, Axes}}) where {T, N, A, Axes} = BC.DefaultArrayStyle{N}()
28+
# Base.BroadcastStyle(::Type{<:ComponentArray{T, N, A, Axes}}) where {T, N, A, Axes} = BC.BroadcastStyle(A)
29+
30+
Base.getindex(bc::BC.Broadcasted, inds::ComponentIndex...) = bc[value.(inds)...]
31+
32+
# Need special case here for adjoint vectors in order to avoid type instability in axistype
33+
BC.combine_axes(a::ComponentArray, b::AdjOrTransComponentVector) = (axes(a)[1], axes(b)[2])
34+
BC.combine_axes(a::AdjOrTransComponentVector, b::ComponentArray) = (axes(b)[2], axes(a)[1])
35+
36+
# BC.axistype(a::CombinedAxis, b::AbstractUnitRange) = Base.Broadcast.axistype(_array_axis(a), b)
37+
# BC.axistype(a::AbstractUnitRange, b::CombinedAxis) = Base.Broadcast.axistype(a, _array_axis(b))
38+
# BC.axistype(a::CombinedAxis, b::CombinedAxis) = Base.Broadcast.axistype(_array_axis(a), _array_axis(b))
39+
BC.axistype(a::CombinedAxis, b::AbstractUnitRange) = a
40+
BC.axistype(a::AbstractUnitRange, b::CombinedAxis) = b
41+
BC.axistype(a::CombinedAxis, b::CombinedAxis) = CombinedAxis(FlatAxis(), Base.Broadcast.axistype(_array_axis(a), _array_axis(b)))
42+
BC.axistype(a::T, b::T) where {T<:CombinedAxis} = a
43+
44+
Base.promote_shape(a::Tuple{Vararg{CombinedAxis}}, b::NTuple{N,AbstractUnitRange}) where N = Base.promote_shape(_array_axis.(a), b)
45+
Base.promote_shape(a::NTuple{N,AbstractUnitRange}, b::Tuple{Vararg{CombinedAxis}}) where N = Base.promote_shape(a, _array_axis.(b))
46+
Base.promote_shape(a::Tuple{Vararg{CombinedAxis}}, b::Tuple{Vararg{CombinedAxis}}) = Base.promote_shape(_array_axis.(a), _array_axis.(b))
47+
# Base.promote_shape(a::Tuple{Vararg{Union{AbstractUnitRange, CombinedAxis}}}, b::Tuple{Vararg{Union{AbstractUnitRange, CombinedAxis}}}) = promote_shape(_array_axis.(a), _array_axis.(b))
48+
Base.promote_shape(a::T, b::T) where {T<:Tuple{Vararg{CombinedAxis}}} = a
49+
50+
# # Hack to make things like Dual.(ComponentArray(a=1,b=1), [1,1]) work
51+
# BC.broadcasted(f::Type, arg1::ComponentArray, args...) = ComponentArray(f.(getdata(arg1), getdata.(args)...), getaxes(arg1))
52+
# BC.broadcasted(f::Type, arg1, arg2::ComponentArray, args...) = ComponentArray(f.(arg1, getdata(arg2), getdata.(args)...), getaxes(arg2))
53+
54+
# function BC.BroadcastStyle(::CAStyle{<:In1, <:Ax1, <:N1}, ::CAStyle{<:In2, <:Ax2, <:N2}) where {In1, Ax1, N1, In2, Ax2, N2}
55+
# ax, N = fill_flat(Ax1, Ax2, N1, N2)
56+
# inner_style = BC.BroadcastStyle(In1(), In2())
57+
# if inner_style isa BC.Unknown
58+
# inner_style = BC.DefaultArrayStyle{N}()
59+
# end
60+
# return CAStyle(inner_style, ax, N)
61+
# end
62+
# function BC.BroadcastStyle(::CAStyle{In, Ax, N1}, ::Style) where Style<:BC.DefaultArrayStyle{N2} where {In, Ax, N1, N2}
63+
# N = max(N1, N2)
64+
# ax = fill_flat(Ax, max(N1, N2))
65+
# inner_style = BC.BroadcastStyle(In(), Style())
66+
# return CAStyle(inner_style, ax, N)
67+
# end
68+
# function BC.BroadcastStyle(CAS::CAStyle{In, Ax, N1}, ::BC.DefaultArrayStyle{0}) where {In, Ax, N1}
69+
# return CAS
70+
# end
71+
# function BC.BroadcastStyle(CAS::CAStyle{In, Ax, N}, ::BC.DefaultArrayStyle{N}) where {In, Ax, N}
72+
# return CAS
73+
# end
74+
# function BC.BroadcastStyle(::CAStyle{In, Ax, N1}, ::Style) where Style<:BC.AbstractArrayStyle{N2} where {In, Ax, N1, N2}
75+
# N = max(N1, N2)
76+
# ax = fill_flat(Ax, max(N1, N2))
77+
# inner_style = BC.BroadcastStyle(In(), Style())
78+
# return CAStyle(inner_style, ax, N)
79+
# end
5480

5581

56-
Base.convert(::Type{<:BC.Broadcasted{Nothing}}, bc::BC.Broadcasted{<:CAStyle,Axes,F,Args}) where {Axes,F,Args} = getdata(bc)
82+
# Base.convert(::Type{<:BC.Broadcasted{Nothing}}, bc::BC.Broadcasted{<:CAStyle,Axes,F,Args}) where {Axes,F,Args} = getdata(bc)
5783

58-
getdata(bc::BC.Broadcasted{<:CAStyle}) = BC.broadcasted(bc.f, map(getdata, bc.args)...)
84+
# getdata(bc::BC.Broadcasted{<:CAStyle}) = BC.broadcasted(bc.f, map(getdata, bc.args)...)
5985

6086

61-
function Base.similar(bc::BC.Broadcasted{<:CAStyle{InnerStyle, Axes, N}}, args...) where {InnerStyle, Axes, N}
62-
return ComponentArray{Axes}(similar(BC.Broadcasted{InnerStyle}(bc.f, bc.args, bc.axes), args...))
63-
end
64-
function Base.similar(bc::BC.Broadcasted{<:CAStyle{InnerStyle, Axes, N}}, T::Type) where {InnerStyle, Axes, N}
65-
return ComponentArray{Axes}(similar(BC.Broadcasted{InnerStyle}(bc.f, bc.args, bc.axes), T))
66-
end
67-
function Base.similar(bc::BC.Broadcasted{<:CAStyle{<:BC.Unknown, Axes, N}}, T::Type) where {InnerStyle, Axes, N}
68-
return ComponentArray{Axes}(similar(BC.Broadcasted{BC.DefaultArrayStyle{N}}(bc.f, bc.args, bc.axes), T))
69-
end
87+
# function Base.similar(bc::BC.Broadcasted{<:CAStyle{InnerStyle, Axes, N}}, args...) where {InnerStyle, Axes, N}
88+
# return similar(BC.Broadcasted{InnerStyle}(bc.f, bc.args, bc.axes), args...)
89+
# end
90+
# function Base.similar(bc::BC.Broadcasted{<:CAStyle{InnerStyle, Axes, N}}, T::Type) where {InnerStyle, Axes, N}
91+
# return similar(BC.Broadcasted{InnerStyle}(bc.f, bc.args, bc.axes), T)
92+
# end
93+
# function Base.similar(bc::BC.Broadcasted{<:CAStyle{<:BC.Unknown, Axes, N}}, T::Type) where {InnerStyle, Axes, N}
94+
# return similar(BC.Broadcasted{BC.DefaultArrayStyle{N}}(bc.f, bc.args, bc.axes), T)
95+
# end
7096

7197

7298
# BC.broadcasted(f, x::ComponentArray) = ComponentArray(map(f, getdata(x)), getaxes(x))
@@ -77,6 +103,7 @@ function Base.map(f, xs::ComponentArray{<:Any, <:Any, <:Any, Axes}...) where Axe
77103
return ComponentArray(map(f, getdata.(xs)...), getaxes(Axes))
78104
end
79105

106+
80107
# function Base.copy(bc::BC.Broadcasted{<:CAStyle{InnerStyle, Axes, N}}) where {InnerStyle, Axes, N}
81108
# return ComponentArray{Axes}(Base.copy(BC.broadcasted(bc.f, map(getdata, bc.args)...)))
82109
# end

src/componentarray.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ const CMatrix = ComponentMatrix
121121

122122
const AdjOrTrans{T, A} = Union{Adjoint{T, A}, Transpose{T, A}}
123123
const AdjOrTransComponentArray{T, A} = Union{Adjoint{T, A}, Transpose{T, A}} where A<:ComponentArray
124+
const AdjOrTransComponentVector{T} = Union{Adjoint{T, A}, Transpose{T, A}} where A<:ComponentVector
124125

125126
const ComponentVecOrMat = Union{ComponentVector, ComponentMatrix}
126127
const AdjOrTransComponentVecOrMat = AdjOrTrans{T, <:ComponentVecOrMat} where T

src/componentindex.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,24 @@ ComponentIndex(idx::Int) = ComponentIndex(idx, NullAxis())
66
ComponentIndex(idx::Union{FlatIdx, Colon}) = ComponentIndex(idx, FlatAxis())
77
ComponentIndex(vax::ViewAxis{Inds,IdxMap,Ax}) where {Inds,IdxMap,Ax} = ComponentIndex(Inds, vax.ax)
88

9+
value(idx::ComponentIndex) = idx.idx
10+
value(idx) = idx
11+
912
const FlatComponentIndex{Idx} = ComponentIndex{Idx, FlatAxis}
1013
const NullComponentIndex{Idx} = ComponentIndex{Idx, NullAxis}
1114

1215
function Base.getindex(A::AbstractArray, ind::ComponentIndex, inds::ComponentIndex...)
1316
inds = (ind, inds...)
1417
return ComponentArray(A[(i.idx for i in inds)...], Tuple(i.ax for i in inds))
1518
end
19+
Base.getindex(A::ComponentArray, ind::ComponentIndex, inds::ComponentIndex...) = getindex(A, ind.idx, (i.idx for i in inds)...)
20+
Base.getindex(bc::Base.Broadcast.Broadcasted{Nothing}, idx::ComponentIndex) = bc[CartesianIndex(idx)]
21+
22+
# Do we still need this?
23+
Base.getindex(ax::AbstractAxis, ind::ComponentIndex) = ax[ind.idx]
24+
25+
Base.CartesianIndex(idx::Union{ComponentIndex, Integer, CartesianIndex}...) = CartesianIndex(value.(idx)...)
26+
1627

1728
"""
1829
KeepIndex(idx)

src/similar_convert_copy.jl

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,62 @@ Base.similar(x::ComponentArray, ::Type{T}) where T = ComponentArray(similar(getd
1111
# return A
1212
# end
1313
# end
14-
function Base.similar(x::ComponentArray{T1,N,A,Ax}, ::Type{T}, dims::NTuple{N,Int}) where {T,T1,N,A,Ax}
15-
arr = similar(getdata(x), T, dims)
16-
return ComponentArray(arr, getaxes(x))
14+
# function Base.similar(x::ComponentArray{T1,N,A,Ax}, ::Type{T}, dims::Union{Integer, AbstractUnitRange}...) where {T,T1,N,A,Ax}
15+
# arr = similar(getdata(x), T, dims)
16+
# return ComponentArray(arr, getaxes(x))
17+
# end
18+
# function Base.similar(x::ComponentArray{T1,N,A,Ax}, ::Type{T}, dims::Union{Integer, AbstractUnitRange}...) where {T,T1,N,A,Ax}
19+
# return similar(getdata(x), T, dims)
20+
# end
21+
function Base.similar(x::AbstractArray, dims::Tuple{<:CombinedAxis, Vararg{<:CombinedOrRegularAxis}})
22+
arr = similar(getdata(x), length.(_array_axis.(dims)))
23+
return ComponentArray(arr, _component_axis.(dims)...)
24+
end
25+
function Base.similar(x::AbstractArray, dims::Tuple{<:Union{Integer,AbstractUnitRange}, <:CombinedAxis, Vararg{<:CombinedOrRegularAxis}})
26+
arr = similar(getdata(x), length.(_array_axis.(dims)))
27+
return ComponentArray(arr, _component_axis.(dims)...)
28+
end
29+
function Base.similar(x::AbstractArray, dims::Tuple{<:CombinedAxis, <:CombinedAxis, Vararg{<:CombinedOrRegularAxis}})
30+
arr = similar(getdata(x), length.(_array_axis.(dims)))
31+
return ComponentArray(arr, _component_axis.(dims)...)
32+
end
33+
function Base.similar(x::AbstractArray, ::Type{T}, dims::Tuple{<:CombinedAxis, Vararg{<:CombinedOrRegularAxis}}) where {T}
34+
arr = similar(getdata(x), T, length.(_array_axis.(dims)))
35+
return ComponentArray(arr, _component_axis.(dims)...)
36+
end
37+
function Base.similar(x::AbstractArray, ::Type{T}, dims::Tuple{<:Union{Integer,AbstractUnitRange}, <:CombinedAxis, Vararg{<:CombinedOrRegularAxis}}) where {T}
38+
arr = similar(getdata(x), T, length.(_array_axis.(dims)))
39+
return ComponentArray(arr, _component_axis.(dims)...)
40+
end
41+
function Base.similar(x::Type{<:AbstractArray}, dims::Tuple{<:CombinedAxis, Vararg{<:CombinedOrRegularAxis}})
42+
arr = similar(x, length.(_array_axis.(dims)))
43+
return ComponentArray(arr, _component_axis.(dims)...)
1744
end
18-
function Base.similar(x::ComponentArray{T1,N1,A,Ax}, ::Type{T}, dims::NTuple{N2,Int}) where {T,T1,N1,N2,A,Ax}
19-
return similar(getdata(x), T, dims)
45+
function Base.similar(x::Type{<:AbstractArray}, dims::Tuple{<:CombinedOrRegularAxis, <:CombinedAxis, Vararg{<:CombinedOrRegularAxis}})
46+
arr = similar(x, length.(_array_axis.(dims)))
47+
return ComponentArray(arr, _component_axis.(dims)...)
2048
end
49+
function Base.similar(x::Type{<:AbstractArray}, dims::Tuple{<:CombinedAxis, <:CombinedAxis, Vararg{<:CombinedOrRegularAxis}})
50+
arr = similar(x, length.(_array_axis.(dims)))
51+
return ComponentArray(arr, _component_axis.(dims)...)
52+
end
53+
54+
# function Base.similar(A::Type{<:AbstractArray}, dims::Tuple{<:AbstractAxis,Vararg{<:AbstractAxis}})
55+
# arr = similar(A, length.(dims))
56+
# return ComponentArray(arr, Axis.(dims))
57+
# end
58+
# function Base.similar(A::Type{<:AbstractArray}, ::Type{T}, dims::Tuple{<:AbstractAxis,Vararg{<:AbstractAxis}}) where {T}
59+
# arr = similar(A, T, length.(dims))
60+
# return ComponentArray(arr, Axis.(dims))
61+
# end
62+
# function Base.similar(A::Type{<:AbstractArray}, dims::Tuple{<:UnitRange,Vararg{<:AbstractAxis}})
63+
# arr = similar(A, length.(dims))
64+
# return ComponentArray(arr, Axis.(dims))
65+
# end
66+
# function Base.similar(A::Type{<:AbstractArray}, ::Type{T}, dims::Tuple{<:UnitRange,Vararg{<:AbstractAxis}}) where {T}
67+
# arr = similar(A, T, length.(dims))
68+
# return ComponentArray(arr, Axis.(dims))
69+
# end
2170

2271
## TODO: write length method for AbstractAxis so we can do this?
2372
# function Base.similar(::Type{CA}) where CA<:ComponentArray{T,N,A,Axes} where {T,N,A,Axes}

test/diffeq_test/Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[deps]
2+
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
3+
FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
4+
LabelledArrays = "2ee39098-c373-598a-b85f-a56591580800"
5+
Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
6+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7+
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

0 commit comments

Comments
 (0)