Skip to content

Commit a0770e4

Browse files
committed
Revert "formatting"
This reverts commit f4675f2.
1 parent f4675f2 commit a0770e4

File tree

2 files changed

+35
-41
lines changed

2 files changed

+35
-41
lines changed

src/vector_of_array.jl

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ returns a vector of the series for each component, that is, `A[i,:]` for each `i
2929
A plot recipe is provided, which plots the `A[i,:]` series.
3030
3131
There is also support for `VectorOfArray` constructed from multi-dimensional arrays
32-
3332
```julia
3433
VectorOfArray(u::AbstractArray{AT}) where {T, N, AT <: AbstractArray{T, N}}
3534
```
@@ -352,53 +351,48 @@ Base.@propagate_inbounds function _getindex(A::AbstractDiffEqArray, ::NotSymboli
352351
end
353352

354353
struct ParameterIndexingError <: Exception
355-
sym::Any
354+
sym
356355
end
357356

358357
function Base.showerror(io::IO, pie::ParameterIndexingError)
359-
print(io,
360-
"Indexing with parameters is deprecated. Use `getp(A, $(pie.sym))` for parameter indexing.")
358+
print(io, "Indexing with parameters is deprecated. Use `getp(A, $(pie.sym))` for parameter indexing.")
361359
end
362360

363361
# Symbolic Indexing Methods
364362
for (symtype, elsymtype, valtype, errcheck) in [
365-
(ScalarSymbolic, SymbolicIndexingInterface.SymbolicTypeTrait,
366-
Any, :(is_parameter(A, sym))),
367-
(ArraySymbolic, SymbolicIndexingInterface.SymbolicTypeTrait,
368-
Any, :(is_parameter(A, sym))),
369-
(NotSymbolic, SymbolicIndexingInterface.SymbolicTypeTrait,
370-
Union{<:Tuple, <:AbstractArray},
371-
:(all(x -> is_parameter(A, x), sym)))
363+
(ScalarSymbolic, SymbolicIndexingInterface.SymbolicTypeTrait, Any, :(is_parameter(A, sym))),
364+
(ArraySymbolic, SymbolicIndexingInterface.SymbolicTypeTrait, Any, :(is_parameter(A, sym))),
365+
(NotSymbolic, SymbolicIndexingInterface.SymbolicTypeTrait, Union{<:Tuple, <:AbstractArray},
366+
:(all(x -> is_parameter(A, x), sym))),
372367
]
373-
@eval Base.@propagate_inbounds function _getindex(A::AbstractDiffEqArray, ::$symtype,
374-
::$elsymtype, sym::$valtype)
375-
if $errcheck
376-
throw(ParameterIndexingError(sym))
377-
end
378-
getu(A, sym)(A)
368+
@eval Base.@propagate_inbounds function _getindex(A::AbstractDiffEqArray, ::$symtype,
369+
::$elsymtype, sym::$valtype)
370+
if $errcheck
371+
throw(ParameterIndexingError(sym))
379372
end
380-
@eval Base.@propagate_inbounds function _getindex(A::AbstractDiffEqArray, ::$symtype,
381-
::$elsymtype, sym::$valtype, arg)
382-
if $errcheck
383-
throw(ParameterIndexingError(sym))
384-
end
385-
getu(A, sym)(A, arg)
373+
getu(A, sym)(A)
374+
end
375+
@eval Base.@propagate_inbounds function _getindex(A::AbstractDiffEqArray, ::$symtype,
376+
::$elsymtype, sym::$valtype, arg)
377+
if $errcheck
378+
throw(ParameterIndexingError(sym))
386379
end
387-
@eval Base.@propagate_inbounds function _getindex(A::AbstractDiffEqArray, ::$symtype,
388-
::$elsymtype, sym::$valtype, arg::Union{
389-
AbstractArray{Int}, AbstractArray{Bool}})
390-
if $errcheck
391-
throw(ParameterIndexingError(sym))
392-
end
393-
getu(A, sym).((A,), arg)
380+
getu(A, sym)(A, arg)
381+
end
382+
@eval Base.@propagate_inbounds function _getindex(A::AbstractDiffEqArray, ::$symtype,
383+
::$elsymtype, sym::$valtype, arg::Union{AbstractArray{Int}, AbstractArray{Bool}})
384+
if $errcheck
385+
throw(ParameterIndexingError(sym))
394386
end
395-
@eval Base.@propagate_inbounds function _getindex(A::AbstractDiffEqArray, ::$symtype,
396-
::$elsymtype, sym::$valtype, ::Colon)
397-
if $errcheck
398-
throw(ParameterIndexingError(sym))
399-
end
400-
getu(A, sym)(A)
387+
getu(A, sym).((A,), arg)
388+
end
389+
@eval Base.@propagate_inbounds function _getindex(A::AbstractDiffEqArray, ::$symtype,
390+
::$elsymtype, sym::$valtype, ::Colon)
391+
if $errcheck
392+
throw(ParameterIndexingError(sym))
401393
end
394+
getu(A, sym)(A)
395+
end
402396
end
403397

404398
Base.@propagate_inbounds function _getindex(A::AbstractDiffEqArray, ::ScalarSymbolic,
@@ -416,9 +410,8 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractVectorOfArray, _arg,
416410
elsymtype = symbolic_type(eltype(_arg))
417411

418412
if symtype == NotSymbolic() && elsymtype == NotSymbolic()
419-
if _arg isa Union{Tuple, AbstractArray} &&
420-
any(x -> symbolic_type(x) != NotSymbolic(), _arg)
421-
_getindex(A, symtype, elsymtype, _arg, args...)
413+
if _arg isa Union{Tuple, AbstractArray} && any(x -> symbolic_type(x) != NotSymbolic(), _arg)
414+
_getindex(A, symtype, elsymtype, _arg, args...)
422415
else
423416
_getindex(A, symtype, _arg, args...)
424417
end
@@ -734,6 +727,7 @@ function Base.similar(vec::VectorOfArray{
734727
return Base.similar(vec, eltype(vec))
735728
end
736729

730+
737731
# fill!
738732
# For DiffEqArray it ignores ts and fills only u
739733
function Base.fill!(VA::AbstractVectorOfArray, x)

test/basic_indexing.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ function foo!(u)
248248
end
249249
foo!(u_matrix)
250250
foo!(u_vector)
251-
@test all(u_matrix .== [3, 10])
251+
@test all(u_matrix .== [3, 10])
252252
@test all(vec(u_matrix) .≈ vec(u_vector))
253253

254254
# test that, for VectorOfArray with multi-dimensional parent arrays,
255255
# broadcast and `similar` preserve the structure of the parent array
256256
@test typeof(parent(similar(u_matrix))) == typeof(parent(u_matrix))
257-
@test typeof(parent((x -> x).(u_matrix))) == typeof(parent(u_matrix))
257+
@test typeof(parent((x->x).(u_matrix))) == typeof(parent(u_matrix))
258258

259259
# test efficiency
260260
num_allocs = @allocations foo!(u_matrix)

0 commit comments

Comments
 (0)