Skip to content

Commit

Permalink
update scan to use AbstractModel
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Feb 28, 2024
1 parent c1f0781 commit 84dae82
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions EpiAware/src/utilities.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

"""
scan(f::F, init, xs) where {F <: AbstractEpiModel}
scan(f::F, init, xs) where {F <: AbstractModel}
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 `AbstractEpiModel`.
### Design note
`scan` is being restricted to `AbstractEpiModel` sub-types to ensure:
`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`.
Expand All @@ -26,7 +26,7 @@ Apply `f` to each element of `xs` and accumulate the results.
- `carry`: The final value of the `carry` variable after processing all elements of `xs`.
"""
function scan(f::F, init, xs) where {F <: AbstractEpiModel}
function scan(f::F, init, xs) where {F <: AbstractModel}
carry = init
ys = similar(xs)
for (i, x) in enumerate(xs)
Expand Down

0 comments on commit 84dae82

Please sign in to comment.