From 0fea2aeb3aeab2bc6a733f60bf77529179dc90fb Mon Sep 17 00:00:00 2001 From: Azzaare Date: Sat, 5 Oct 2024 14:20:26 +0900 Subject: [PATCH 1/2] Update doc --- src/layers/comparison.jl | 21 +++++++++++++-------- src/utils.jl | 6 ++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/layers/comparison.jl b/src/layers/comparison.jl index 78bf860..20c6cb0 100644 --- a/src/layers/comparison.jl +++ b/src/layers/comparison.jl @@ -35,7 +35,7 @@ end Compute an euclidean norm with domain size `dom_size` of a scalar. """ function co_euclidean(x; dom_size, params...) - return co_euclidean_val(x; val = 0.0, dom_size) + return co_euclidean_val(x; val=0.0, dom_size) end """ @@ -48,16 +48,21 @@ co_abs_diff_var_vars(x; nvars, params...) = abs(x - nvars) co_var_minus_vars(x; nvars) Return the difference `x - nvars` if positive, `0.0` otherwise, where `nvars` denotes the numbers of variables. """ -co_var_minus_vars(x; nvars, params...) = co_var_minus_val(x; val = nvars) +co_var_minus_vars(x; nvars, params...) = co_var_minus_val(x; val=nvars) """ co_vars_minus_var(x; nvars) Return the difference `nvars - x` if positive, `0.0` otherwise, where `nvars` denotes the numbers of variables. """ -co_vars_minus_var(x; nvars, params...) = co_val_minus_var(x; val = nvars) +co_vars_minus_var(x; nvars, params...) = co_val_minus_var(x; val=nvars) # Parametric layers +""" + make_comparisons(param::Symbol) + +Generate the comparison functions for the given parameter. +""" make_comparisons(param::Symbol) = make_comparisons(Val(param)) function make_comparisons(::Val{:none}) @@ -84,7 +89,7 @@ end comparison_layer(param = false) Generate the layer of transformations functions of the ICN. Iff `param` value is set, also includes all the parametric comparison with that value. The operations are mutually exclusive, that is only one will be selected. """ -function comparison_layer(parameters = Vector{Symbol}()) +function comparison_layer(parameters=Vector{Symbol}()) comparisons = make_comparisons(:none) for p in parameters @@ -118,7 +123,7 @@ end for (f, results) in funcs_param for (key, vals) in enumerate(data) - @test f(vals.first; val = vals.second[1]) == results[key] + @test f(vals.first; val=vals.second[1]) == results[key] end end @@ -130,7 +135,7 @@ end for (f, results) in funcs_vars for (key, vals) in enumerate(data) - @test f(vals.first, nvars = vals.second[2]) == results[key] + @test f(vals.first, nvars=vals.second[2]) == results[key] end end @@ -138,7 +143,7 @@ end for (f, results) in funcs_val_dom for (key, vals) in enumerate(data) - @test f(vals.first, val = vals.second[1], dom_size = vals.second[2]) ≈ + @test f(vals.first, val=vals.second[1], dom_size=vals.second[2]) ≈ results[key] end end @@ -147,7 +152,7 @@ end for (f, results) in funcs_dom for (key, vals) in enumerate(data) - @test f(vals.first, dom_size = vals.second[2]) ≈ results[key] + @test f(vals.first, dom_size=vals.second[2]) ≈ results[key] end end diff --git a/src/utils.jl b/src/utils.jl index 50cb474..8405c55 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -57,7 +57,7 @@ end as_bitvector(n::Int, max_n::Int = n) Convert an Int to a BitVector of minimal size (relatively to `max_n`). """ -function as_bitvector(n::Int, max_n::Int = n) +function as_bitvector(n::Int, max_n::Int=n) nm1 = n - 1 v = falses(ceil(Int, log2(max_n))) i = 0 @@ -86,7 +86,7 @@ end reduce_symbols(symbols, sep) Produce a formatted string that separates the symbols by `sep`. Used internally for `show_composition`. """ -function reduce_symbols(symbols, sep, parenthesis = true; prefix = "") +function reduce_symbols(symbols, sep, parenthesis=true; prefix="") str = reduce((x, y) -> "$y$sep$x", map(s -> "$prefix$s", symbols)) return parenthesis ? "[$str]" : str end @@ -96,6 +96,8 @@ end Application of an operation from the transformation layer. Used to generate more efficient code for all compositions. """ +function tr_in end + @unroll function tr_in(tr, X, x; params...) @unroll for i = 1:length(tr) tr[i](x, @view(X[:, i]); params...) From 68d6caf294262422d23835caf0447d4663598d1c Mon Sep 17 00:00:00 2001 From: Azzaare Date: Tue, 8 Oct 2024 14:55:04 +0900 Subject: [PATCH 2/2] Fix compat --- .github/workflows/ci.yml | 1 - Project.toml | 2 +- src/layers/comparison.jl | 16 ++++++++-------- src/utils.jl | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0749fd6..1468070 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,6 @@ jobs: fail-fast: false matrix: version: - - "1.9" - "1" # automatically expands to the latest stable 1.x release of Julia - "pre" os: diff --git a/Project.toml b/Project.toml index b50be0d..742ed31 100644 --- a/Project.toml +++ b/Project.toml @@ -24,7 +24,7 @@ OrderedCollections = "1" Random = "1" TestItems = "0.1, 1" Unrolled = "0.1" -julia = "1.9" +julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" diff --git a/src/layers/comparison.jl b/src/layers/comparison.jl index 20c6cb0..5f5bed5 100644 --- a/src/layers/comparison.jl +++ b/src/layers/comparison.jl @@ -35,7 +35,7 @@ end Compute an euclidean norm with domain size `dom_size` of a scalar. """ function co_euclidean(x; dom_size, params...) - return co_euclidean_val(x; val=0.0, dom_size) + return co_euclidean_val(x; val = 0.0, dom_size) end """ @@ -48,13 +48,13 @@ co_abs_diff_var_vars(x; nvars, params...) = abs(x - nvars) co_var_minus_vars(x; nvars) Return the difference `x - nvars` if positive, `0.0` otherwise, where `nvars` denotes the numbers of variables. """ -co_var_minus_vars(x; nvars, params...) = co_var_minus_val(x; val=nvars) +co_var_minus_vars(x; nvars, params...) = co_var_minus_val(x; val = nvars) """ co_vars_minus_var(x; nvars) Return the difference `nvars - x` if positive, `0.0` otherwise, where `nvars` denotes the numbers of variables. """ -co_vars_minus_var(x; nvars, params...) = co_val_minus_var(x; val=nvars) +co_vars_minus_var(x; nvars, params...) = co_val_minus_var(x; val = nvars) # Parametric layers @@ -89,7 +89,7 @@ end comparison_layer(param = false) Generate the layer of transformations functions of the ICN. Iff `param` value is set, also includes all the parametric comparison with that value. The operations are mutually exclusive, that is only one will be selected. """ -function comparison_layer(parameters=Vector{Symbol}()) +function comparison_layer(parameters = Vector{Symbol}()) comparisons = make_comparisons(:none) for p in parameters @@ -123,7 +123,7 @@ end for (f, results) in funcs_param for (key, vals) in enumerate(data) - @test f(vals.first; val=vals.second[1]) == results[key] + @test f(vals.first; val = vals.second[1]) == results[key] end end @@ -135,7 +135,7 @@ end for (f, results) in funcs_vars for (key, vals) in enumerate(data) - @test f(vals.first, nvars=vals.second[2]) == results[key] + @test f(vals.first, nvars = vals.second[2]) == results[key] end end @@ -143,7 +143,7 @@ end for (f, results) in funcs_val_dom for (key, vals) in enumerate(data) - @test f(vals.first, val=vals.second[1], dom_size=vals.second[2]) ≈ + @test f(vals.first, val = vals.second[1], dom_size = vals.second[2]) ≈ results[key] end end @@ -152,7 +152,7 @@ end for (f, results) in funcs_dom for (key, vals) in enumerate(data) - @test f(vals.first, dom_size=vals.second[2]) ≈ results[key] + @test f(vals.first, dom_size = vals.second[2]) ≈ results[key] end end diff --git a/src/utils.jl b/src/utils.jl index 8405c55..991833e 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -57,7 +57,7 @@ end as_bitvector(n::Int, max_n::Int = n) Convert an Int to a BitVector of minimal size (relatively to `max_n`). """ -function as_bitvector(n::Int, max_n::Int=n) +function as_bitvector(n::Int, max_n::Int = n) nm1 = n - 1 v = falses(ceil(Int, log2(max_n))) i = 0 @@ -86,7 +86,7 @@ end reduce_symbols(symbols, sep) Produce a formatted string that separates the symbols by `sep`. Used internally for `show_composition`. """ -function reduce_symbols(symbols, sep, parenthesis=true; prefix="") +function reduce_symbols(symbols, sep, parenthesis = true; prefix = "") str = reduce((x, y) -> "$y$sep$x", map(s -> "$prefix$s", symbols)) return parenthesis ? "[$str]" : str end