Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Feb 21, 2024
1 parent 7983b2b commit 758ac84
Show file tree
Hide file tree
Showing 23 changed files with 491 additions and 383 deletions.
2 changes: 1 addition & 1 deletion docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
pages = [
"Home" => "index.md",
"array_types.md",
"recursive_array_functions.md",
"recursive_array_functions.md"
]
10 changes: 7 additions & 3 deletions ext/RecursiveArrayToolsFastBroadcastExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ using RecursiveArrayTools
using FastBroadcast
using StaticArraysCore

const AbstractVectorOfSArray = AbstractVectorOfArray{T,N,<:AbstractVector{<:StaticArraysCore.SArray}} where {T,N}
const AbstractVectorOfSArray = AbstractVectorOfArray{
T, N, <:AbstractVector{<:StaticArraysCore.SArray}} where {T, N}

@inline function FastBroadcast.fast_materialize!(::FastBroadcast.Static.False, ::DB, dst::AbstractVectorOfSArray, bc::Broadcast.Broadcasted{S}) where {S,DB}
@inline function FastBroadcast.fast_materialize!(
::FastBroadcast.Static.False, ::DB, dst::AbstractVectorOfSArray,
bc::Broadcast.Broadcasted{S}) where {S, DB}
if FastBroadcast.use_fast_broadcast(S)
for i in 1:length(dst.u)
unpacked = RecursiveArrayTools.unpack_voa(bc, i)
dst.u[i] = StaticArraysCore.similar_type(dst.u[i])(unpacked[j] for j in eachindex(unpacked))
dst.u[i] = StaticArraysCore.similar_type(dst.u[i])(unpacked[j]
for j in eachindex(unpacked))
end
else
Broadcast.materialize!(dst, bc)
Expand Down
2 changes: 1 addition & 1 deletion ext/RecursiveArrayToolsMeasurementsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import RecursiveArrayTools
isdefined(Base, :get_extension) ? (import Measurements) : (import ..Measurements)

function RecursiveArrayTools.recursive_unitless_bottom_eltype(a::Type{
<:Measurements.Measurement,
<:Measurements.Measurement,
})
typeof(oneunit(a))
end
Expand Down
4 changes: 2 additions & 2 deletions ext/RecursiveArrayToolsMonteCarloMeasurementsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ isdefined(Base, :get_extension) ? (import MonteCarloMeasurements) :
(import ..MonteCarloMeasurements)

function RecursiveArrayTools.recursive_unitless_bottom_eltype(a::Type{
<:MonteCarloMeasurements.Particles,
<:MonteCarloMeasurements.Particles,
})
typeof(one(a))
end

function RecursiveArrayTools.recursive_unitless_eltype(a::Type{
<:MonteCarloMeasurements.Particles,
<:MonteCarloMeasurements.Particles,
})
typeof(one(a))
end
Expand Down
12 changes: 6 additions & 6 deletions ext/RecursiveArrayToolsReverseDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ using ReverseDiff
using Zygote: @adjoint

function trackedarraycopyto!(dest, src)
for (i, slice) in zip(eachindex(dest.u), eachslice(src, dims=ndims(src)))
if dest.u[i] isa AbstractArray
dest.u[i] = reshape(reduce(vcat, slice), size(dest.u[i]))
else
trackedarraycopyto!(dest.u[i], slice)
end
for (i, slice) in zip(eachindex(dest.u), eachslice(src, dims = ndims(src)))
if dest.u[i] isa AbstractArray
dest.u[i] = reshape(reduce(vcat, slice), size(dest.u[i]))
else
trackedarraycopyto!(dest.u[i], slice)
end
end
end

@adjoint function Array(VA::AbstractVectorOfArray{<:ReverseDiff.TrackedReal})
Expand Down
12 changes: 6 additions & 6 deletions ext/RecursiveArrayToolsTrackerExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import RecursiveArrayTools
isdefined(Base, :get_extension) ? (import Tracker) : (import ..Tracker)

function RecursiveArrayTools.recursivecopy!(b::AbstractArray{T, N},
a::AbstractArray{T2, N}) where {
T <:
Tracker.TrackedArray,
T2 <:
Tracker.TrackedArray,
N}
a::AbstractArray{T2, N}) where {
T <:
Tracker.TrackedArray,
T2 <:
Tracker.TrackedArray,
N}
@inbounds for i in eachindex(a)
b[i] = copy(a[i])
end
Expand Down
Loading

0 comments on commit 758ac84

Please sign in to comment.