From bab886ee166ecb330e6c4de9d53469e9a6291eb1 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 14 Mar 2024 11:45:54 +0000 Subject: [PATCH] clena out utils duplicate --- EpiAware/src/EpiAwareUtils/scan.jl | 34 ------------------------------ 1 file changed, 34 deletions(-) delete mode 100644 EpiAware/src/EpiAwareUtils/scan.jl diff --git a/EpiAware/src/EpiAwareUtils/scan.jl b/EpiAware/src/EpiAwareUtils/scan.jl deleted file mode 100644 index fbd76c5a6..000000000 --- a/EpiAware/src/EpiAwareUtils/scan.jl +++ /dev/null @@ -1,34 +0,0 @@ -""" -Apply `f` to each element of `xs` and accumulate the results. - -`f` must be a [callable](https://docs.julialang.org/en/v1/manual/methods/#Function-like-objects) - on a sub-type of `AbstractModel`. - -### Design note -`scan` is being restricted to `AbstractModel` sub-types to ensure: - 1. That compiler specialization is [activated](https://docs.julialang.org/en/v1/manual/performance-tips/#Be-aware-of-when-Julia-avoids-specializing) - 2. Also avoids potential compiler [overhead](https://docs.julialang.org/en/v1/devdocs/functions/#compiler-efficiency-issues) - from specialisation on `f<: Function`. - - - -# Arguments -- `f`: A callable/functor that takes two arguments, `carry` and `x`, and returns a new - `carry` and a result `y`. -- `init`: The initial value for the `carry` variable. -- `xs`: An iterable collection of elements. - -# Returns -- `ys`: An array containing the results of applying `f` to each element of `xs`. -- `carry`: The final value of the `carry` variable after processing all elements of `xs`. - -""" -function scan(f::F, init, xs) where {F <: EpiAwareBase.AbstractModel} - carry = init - ys = similar(xs) - for (i, x) in enumerate(xs) - carry, y = f(carry, x) - ys[i] = y - end - return ys, carry -end