Skip to content

Commit 7e4cb6d

Browse files
committed
Updated CI and tests. Ambiguities left in Aqua
1 parent 26404c6 commit 7e4cb6d

23 files changed

+239
-377
lines changed

.github/workflows/CompatHelper.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/TagBot.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.

Project.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CompositionalNetworks"
22
uuid = "4b67e4b5-442d-4ef5-b760-3f5df3a57537"
33
authors = ["Jean-François Baffier"]
4-
version = "0.5.5"
4+
version = "0.5.6"
55

66
[deps]
77
ConstraintCommons = "e37357d9-0691-492f-a822-e5ea6a920954"
@@ -21,16 +21,21 @@ ConstraintCommons = "0.2"
2121
ConstraintDomains = "0.3"
2222
Dictionaries = "0.4"
2323
Distances = "0.10"
24-
JuliaFormatter = "0.22, 1"
24+
JuliaFormatter = "1"
2525
OrderedCollections = "1"
26+
Random = "1"
2627
TestItemRunner = "0.2"
2728
TestItems = "0.1"
2829
ThreadSafeDicts = "0.1"
2930
Unrolled = "0.1"
3031
julia = "1.8"
3132

3233
[extras]
34+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
35+
Evolutionary = "86b6b26d-c046-49b6-aa0b-5f0f74682bd6"
36+
Memoization = "6fafb56a-5788-4b4e-91ca-c0cea6611c73"
3337
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
38+
ThreadPools = "b189fb0b-2eb5-4ed4-bc0c-d34c51242431"
3439

3540
[targets]
36-
test = ["Test"]
41+
test = ["Aqua", "Evolutionary", "Memoization", "Test", "ThreadPools"]

docs/make.jl

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ using ConstraintDomains
33
using Documenter
44

55
makedocs(;
6-
modules=[CompositionalNetworks, ConstraintDomains],
7-
authors="Jean-François Baffier",
8-
repo="https://github.com/JuliaConstraints/CompositionalNetworks.jl/blob/{commit}{path}#L{line}",
9-
sitename="CompositionalNetworks.jl",
10-
format=Documenter.HTML(;
11-
prettyurls=get(ENV, "CI", nothing) == "true",
12-
canonical="https://JuliaConstraints.github.io/CompositionalNetworks.jl",
6+
modules = [CompositionalNetworks, ConstraintDomains],
7+
authors = "Jean-François Baffier",
8+
repo = "https://github.com/JuliaConstraints/CompositionalNetworks.jl/blob/{commit}{path}#L{line}",
9+
sitename = "CompositionalNetworks.jl",
10+
format = Documenter.HTML(;
11+
prettyurls = get(ENV, "CI", nothing) == "true",
12+
canonical = "https://JuliaConstraints.github.io/CompositionalNetworks.jl",
1313
assets = ["assets/favicon.ico"; "assets/github_buttons.js"; "assets/custom.css"],
1414
),
15-
pages=[
15+
pages = [
1616
"Home" => "index.md",
1717
"ICNs" => "icn.md",
1818
"Layers" => [
@@ -21,18 +21,12 @@ makedocs(;
2121
"Aggregation" => "aggregation.md",
2222
"Comparison" => "comparison.md",
2323
],
24-
"Dependencies" => [
25-
"ConstraintDomains.jl" => "domain.md",
26-
],
27-
"Library" => [
28-
"public.md",
29-
"internal.md",
30-
],
24+
"Dependencies" => ["ConstraintDomains.jl" => "domain.md"],
25+
"Library" => ["public.md", "internal.md"],
3126
],
3227
)
3328

3429
deploydocs(;
35-
repo="github.com/JuliaConstraints/CompositionalNetworks.jl.git",
36-
devbranch="main",
30+
repo = "github.com/JuliaConstraints/CompositionalNetworks.jl.git",
31+
devbranch = "main",
3732
)
38-

perf/allocs.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,13 @@ using ConstraintDomains
2424
alloc() = explore_learn_compose(domains, allunique)
2525

2626
# Actual call to PerfChecker
27-
alloc_check(title, dependencies, targets, pre_alloc, alloc; path=@__DIR__, threads=10)
27+
alloc_check(
28+
title,
29+
dependencies,
30+
targets,
31+
pre_alloc,
32+
alloc;
33+
path = @__DIR__,
34+
threads = 10,
35+
)
2836
end

perf/bench.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ domains = fill(domain([1, 2, 3, 4]), 4)
1414
foreach(_ -> explore_learn_compose(domains, allunique), 1:10)
1515

1616
# Code being benchmarked
17-
t = @benchmark explore_learn_compose(domains, allunique) evals=1 samples=10 seconds=3600
17+
t = @benchmark explore_learn_compose(domains, allunique) evals = 1 samples = 10 seconds =
18+
3600
1819

1920
# Store the bench results
20-
store_benchmark(t, target; path=@__DIR__)
21+
store_benchmark(t, target; path = @__DIR__)

src/composition.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end
2424
2525
Access the code of a composition `c` in a given language `lang`. The name of the generated method is optional.
2626
"""
27-
function code(c::Composition, lang=:maths; name="composition")
27+
function code(c::Composition, lang = :maths; name = "composition")
2828
return get!(c.code, lang, generate(c, name, Val(lang)))
2929
end
3030

@@ -46,7 +46,7 @@ symbols(c::Composition) = c.symbols
4646
compose(icn, weigths=nothing)
4747
Return a function composed by some of the operations of a given ICN. Can be applied to any vector of variables. If `weigths` are given, will assign to `icn`.
4848
"""
49-
function compose(icn::ICN, weigths::BitVector=BitVector())
49+
function compose(icn::ICN, weigths::BitVector = BitVector())
5050
!isempty(weigths) && weigths!(icn, weigths)
5151
composition, symbols = _compose(icn)
5252
return Composition(composition, symbols)
@@ -69,10 +69,10 @@ function generate(c::Composition, name, ::Val{:Julia})
6969
tr_length = length(symbs[1])
7070

7171
CN = "CompositionalNetworks."
72-
tr = reduce_symbols(symbs[1], ", "; prefix=CN * "tr_")
73-
ar = reduce_symbols(symbs[2], ", ", false; prefix=CN * "ar_")
74-
ag = reduce_symbols(symbs[3], ", ", false; prefix=CN * "ag_")
75-
co = reduce_symbols(symbs[4], ", ", false; prefix=CN * "co_")
72+
tr = reduce_symbols(symbs[1], ", "; prefix = CN * "tr_")
73+
ar = reduce_symbols(symbs[2], ", ", false; prefix = CN * "ar_")
74+
ag = reduce_symbols(symbs[3], ", ", false; prefix = CN * "ag_")
75+
co = reduce_symbols(symbs[4], ", ", false; prefix = CN * "co_")
7676

7777
documentation = """\"\"\"
7878
$name(x; X = zeros(length(x), $tr_length), param=nothing, dom_size)
@@ -91,15 +91,15 @@ function generate(c::Composition, name, ::Val{:Julia})
9191
return $ag(@view X[:, 1]) |> (y -> $co(y; param, dom_size, nvars=length(x)))
9292
end
9393
"""
94-
return documentation * format_text(output, BlueStyle(); pipe_to_function_call=false)
94+
return documentation * format_text(output, BlueStyle(); pipe_to_function_call = false)
9595
end
9696

9797
"""
9898
composition_to_file!(c::Composition, path, name, language=:Julia)
9999
100100
Write the composition code in a given `language` into a file at `path`.
101101
"""
102-
function composition_to_file!(c::Composition, path, name, language=:Julia)
102+
function composition_to_file!(c::Composition, path, name, language = :Julia)
103103
output = code(c, language; name)
104104
write(path, output)
105105
return nothing

src/icn.jl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ mutable struct ICN
1717
weigths::BitVector
1818

1919
function ICN(;
20-
param=Vector{Symbol}(),
21-
tr_layer=transformation_layer(param),
22-
ar_layer=arithmetic_layer(),
23-
ag_layer=aggregation_layer(),
24-
co_layer=comparison_layer(param)
20+
param = Vector{Symbol}(),
21+
tr_layer = transformation_layer(param),
22+
ar_layer = arithmetic_layer(),
23+
ag_layer = aggregation_layer(),
24+
co_layer = comparison_layer(param),
2525
)
2626
w = generate_weigths([tr_layer, ar_layer, ag_layer, co_layer])
2727
return new(tr_layer, ar_layer, ag_layer, co_layer, w)
@@ -107,7 +107,7 @@ function regularization(icn)
107107
return Σop / (Σmax + 1)
108108
end
109109

110-
max_icn_length(icn=ICN(; param=[:val])) = length(icn.transformation)
110+
max_icn_length(icn = ICN(; param = [:val])) = length(icn.transformation)
111111

112112
"""
113113
_compose(icn)
@@ -116,8 +116,7 @@ Internal function called by `compose` and `show_composition`.
116116
function _compose(icn::ICN)
117117
!is_viable(icn) && (
118118
return (
119-
(x; X=zeros(length(x), max_icn_length()), param=nothing, dom_size=0) ->
120-
typemax(Float64)
119+
(x; X = zeros(length(x), max_icn_length()), param = nothing, dom_size = 0) -> typemax(Float64)
121120
),
122121
[]
123122
)
@@ -152,11 +151,17 @@ function _compose(icn::ICN)
152151
end
153152
end
154153

155-
function composition(x; X=zeros(length(x), length(funcs[1])), param=nothing, dom_size)
154+
function composition(
155+
x;
156+
X = zeros(length(x), length(funcs[1])),
157+
param = nothing,
158+
dom_size,
159+
)
156160
tr_in(Tuple(funcs[1]), X, x, param)
157-
X[1:length(x), 1] .= 1:length(x) .|> (i -> funcs[2][1](@view X[i, 1:length(funcs[1])]))
158-
return (y -> funcs[4][1](y; param, dom_size, nvars=length(x)))(
159-
funcs[3][1](@view X[:, 1])
161+
X[1:length(x), 1] .=
162+
1:length(x) .|> (i -> funcs[2][1](@view X[i, 1:length(funcs[1])]))
163+
return (y -> funcs[4][1](y; param, dom_size, nvars = length(x)))(
164+
funcs[3][1](@view X[:, 1]),
160165
)
161166
end
162167

src/layer.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A structure to store a `LittleDict` of operations that can be selected during th
44
"""
55
struct Layer
66
exclusive::Bool
7-
functions::LittleDict{Symbol, Function}
7+
functions::LittleDict{Symbol,Function}
88
parameters::Vector{Symbol}
99
end
1010

@@ -83,10 +83,11 @@ end
8383
Generate the weigths of a collection of layers or of an ICN.
8484
"""
8585
function generate_weigths(layers)
86-
bitvecs = map(l -> exclu(l) ?
87-
generate_exclusive_operation(length(l)) :
86+
bitvecs = map(
87+
l ->
88+
exclu(l) ? generate_exclusive_operation(length(l)) :
8889
generate_inclusive_operations(any, length(l)),
89-
layers
90+
layers,
9091
)
9192
return vcat(bitvecs...)
9293
end

src/layers/aggregation.jl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ ag_count_positive(x) = count(y -> y > 0.0, x)
1515
Generate the layer of aggregations of the ICN. The operations are mutually exclusive, that is only one will be selected.
1616
"""
1717
function aggregation_layer()
18-
aggregations = LittleDict{Symbol, Function}(
19-
:sum => ag_sum,
20-
:count_positive => ag_count_positive,
21-
)
18+
aggregations =
19+
LittleDict{Symbol,Function}(:sum => ag_sum, :count_positive => ag_count_positive)
2220

2321
return Layer(true, aggregations, Vector{Symbol}())
2422
end
@@ -27,10 +25,7 @@ end
2725
@testitem "Aggregation Layer" tags = [:aggregation, :layer] begin
2826
CN = CompositionalNetworks
2927

30-
data = [
31-
[1, 5, 2, 4, 3] => 2,
32-
[1, 2, 3, 2, 1] => 2,
33-
]
28+
data = [[1, 5, 2, 4, 3] => 2, [1, 2, 3, 2, 1] => 2]
3429

3530
@test CN.ag_sum(data[1].first) == 15
3631
@test CN.ag_sum(data[2].first) == 9

0 commit comments

Comments
 (0)