Skip to content

Commit cf8b4b2

Browse files
authored
Update to use package extensions (#5)
* update to use package extensions * try to make aqua happy * add ext to extras
1 parent a1654c7 commit cf8b4b2

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

Project.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Folds"
22
uuid = "41a02a25-b8f0-4f67-bc48-60067656b558"
33
authors = ["Takafumi Arakaki <[email protected]> and contributors"]
4-
version = "0.2.9"
4+
version = "0.2.10"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
@@ -26,16 +26,24 @@ DefineSingletons = "0.1.1"
2626
ExternalDocstrings = "0.1"
2727
InitialValues = "0.2.10, 0.3"
2828
MicroCollections = "0.1, 0.2"
29+
OnlineStatsBase = "1"
2930
Referenceables = "0.1.2"
3031
Requires = "0.5, 1.0"
3132
ThreadedScans = "0.1"
3233
Transducers = "0.4.35"
3334
julia = "1.6"
3435

36+
[extensions]
37+
FoldsOnlineStatsBaseExt = "OnlineStatsBase"
38+
3539
[extras]
3640
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3741
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
42+
OnlineStatsBase = "925886fa-5bf2-5e8e-b522-a9147a512338"
3843
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3944

4045
[targets]
4146
test = ["Aqua", "Documenter", "Test"]
47+
48+
[weakdeps]
49+
OnlineStatsBase = "925886fa-5bf2-5e8e-b522-a9147a512338"

src/interop/onlinestats.jl renamed to ext/FoldsOnlineStatsBaseExt.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
module FoldsOnlineStatsBaseExt
2+
3+
@static if isdefined(Base, :get_extension)
4+
using Folds: Folds
5+
using Folds.Implementations: FoldsInit, SequentialEx, Executor, reducingfunction
6+
using OnlineStatsBase: OnlineStatsBase
7+
else
8+
using ..Folds: Folds
9+
using ..Folds.Implementations: FoldsInit, SequentialEx, Executor, reducingfunction
10+
using ..OnlineStatsBase: OnlineStatsBase
11+
end
12+
113
function Folds.reduce(stat::OnlineStatsBase.OnlineStat, itr, ex::Executor; init = FoldsInit)
214
ex isa SequentialEx || validate_reduce_ostat(stat)
315
return Folds.reduce(reducingfunction(stat), itr, ex; init = init)
@@ -14,3 +26,5 @@ function validate_reduce_ostat(stat)
1426
end
1527
return stat
1628
end
29+
30+
end

src/Folds.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ include("collect.jl")
109109
include("misc.jl")
110110

111111
function __init__()
112-
@require OnlineStatsBase="925886fa-5bf2-5e8e-b522-a9147a512338" begin
113-
include("interop/onlinestats.jl")
112+
@static if !isdefined(Base, :get_extension)
113+
@require OnlineStatsBase="925886fa-5bf2-5e8e-b522-a9147a512338" begin
114+
include("../ext/FoldsOnlineStatsBaseExt.jl")
115+
end
114116
end
115117
end
116118

0 commit comments

Comments
 (0)