From c335a546bd9c868ed92bb54861fc5d7f1c212937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20W=C3=BCrfel?= Date: Wed, 17 Apr 2024 17:04:40 +0200 Subject: [PATCH] run julia formatter --- ext/PreallocationToolsReverseDiffExt.jl | 3 ++- src/PreallocationTools.jl | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ext/PreallocationToolsReverseDiffExt.jl b/ext/PreallocationToolsReverseDiffExt.jl index 4c7f323..54311d2 100644 --- a/ext/PreallocationToolsReverseDiffExt.jl +++ b/ext/PreallocationToolsReverseDiffExt.jl @@ -4,7 +4,8 @@ using PreallocationTools isdefined(Base, :get_extension) ? (import ReverseDiff) : (import ..ReverseDiff) # PreallocationTools https://github.com/SciML/PreallocationTools.jl/issues/39 -function Base.getindex(b::PreallocationTools.LazyBufferCache, u::ReverseDiff.TrackedArray, s = b.sizemap(size(u))) +function Base.getindex(b::PreallocationTools.LazyBufferCache, + u::ReverseDiff.TrackedArray, s = b.sizemap(size(u))) T = ReverseDiff.TrackedArray buf = get!(b.bufs, (T, s)) do # declare type since b.bufs dictionary is untyped diff --git a/src/PreallocationTools.jl b/src/PreallocationTools.jl index 93b5d91..80e3c34 100644 --- a/src/PreallocationTools.jl +++ b/src/PreallocationTools.jl @@ -219,14 +219,18 @@ function similar_type(x::AbstractArray{T}, s::NTuple{N, Integer}) where {T, N} typeof(similar(x, ntuple(Returns(1), N))) end -function get_tmp(b::LazyBufferCache, u::T, s=b.sizemap(size(u))) where {T <: AbstractArray} +function get_tmp( + b::LazyBufferCache, u::T, s = b.sizemap(size(u))) where {T <: AbstractArray} get!(b.bufs, (T, s)) do similar(u, s) # buffer to allocate if it was not found in b.bufs end::similar_type(u, s) # declare type since b.bufs dictionary is untyped end # override the [] method -Base.getindex(b::LazyBufferCache, u::T, s=b.sizemap(size(u))) where {T <: AbstractArray} = get_tmp(b, u, s) +function Base.getindex( + b::LazyBufferCache, u::T, s = b.sizemap(size(u))) where {T <: AbstractArray} + get_tmp(b, u, s) +end # GeneralLazyBufferCache