From b700c2f7161b6032a375b4406d9317921a08a127 Mon Sep 17 00:00:00 2001 From: azzaare Date: Wed, 6 Jan 2021 12:06:18 +0900 Subject: [PATCH 1/4] tentative fix --- src/aggregation.jl | 2 +- src/arithmetic.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aggregation.jl b/src/aggregation.jl index fc16883..1858c28 100644 --- a/src/aggregation.jl +++ b/src/aggregation.jl @@ -2,7 +2,7 @@ _sum(x::V) Aggregate through `+` a vector into a single scalar. """ -_sum(x::V) where {T <: Number, V <: AbstractVector{T}} = reduce(+, x) +_sum(x::V) where {V <: AbstractVector} = reduce(+, x) """ _count_positive(x::V) diff --git a/src/arithmetic.jl b/src/arithmetic.jl index 9cc5f7e..79567a2 100644 --- a/src/arithmetic.jl +++ b/src/arithmetic.jl @@ -3,7 +3,7 @@ _prod(x::W) where {T <: Number, V <: AbstractVector{T}, W <: AbstractVector{V}} Reduce `k = length(x)` vectors through sum/product to a single vector. """ -function _sum(x::W) where {T <: Number, V <: AbstractVector{T}, W <: AbstractVector{V}} +function _sum(x::W) where {W <: AbstractVector{AbstractVector}} return reduce((y, z) -> y .+ z, x) end function _prod(x::W) where {T <: Number, V <: AbstractVector{T}, W <: AbstractVector{V}} From eb6a02db2772815987c385f45545748abf1179ed Mon Sep 17 00:00:00 2001 From: azzaare Date: Wed, 6 Jan 2021 12:51:03 +0900 Subject: [PATCH 2/4] Renamed sum into ar_sum, ag_sum ... --- src/aggregation.jl | 4 ++-- src/arithmetic.jl | 12 ++++-------- test/layers.jl | 8 ++++---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/aggregation.jl b/src/aggregation.jl index 1858c28..a0fbf38 100644 --- a/src/aggregation.jl +++ b/src/aggregation.jl @@ -2,7 +2,7 @@ _sum(x::V) Aggregate through `+` a vector into a single scalar. """ -_sum(x::V) where {V <: AbstractVector} = reduce(+, x) +_ag_sum(x) = reduce(+, x) """ _count_positive(x::V) @@ -16,7 +16,7 @@ Generate the layer of aggregation functions of the ICN. """ function aggregation_layer() aggregations = LittleDict{Symbol, Function}( - :sum => _sum, + :sum => _ag_sum, :count_positive => _count_positive, ) diff --git a/src/arithmetic.jl b/src/arithmetic.jl index 79567a2..d5d193b 100644 --- a/src/arithmetic.jl +++ b/src/arithmetic.jl @@ -3,12 +3,8 @@ _prod(x::W) where {T <: Number, V <: AbstractVector{T}, W <: AbstractVector{V}} Reduce `k = length(x)` vectors through sum/product to a single vector. """ -function _sum(x::W) where {W <: AbstractVector{AbstractVector}} - return reduce((y, z) -> y .+ z, x) -end -function _prod(x::W) where {T <: Number, V <: AbstractVector{T}, W <: AbstractVector{V}} - return reduce((y, z) -> y .* z, x) -end +_ar_sum(x) = reduce((y, z) -> y .+ z, x) +_ar_prod(x) = reduce((y, z) -> y .* z, x) """ arithmetic_layer() @@ -16,8 +12,8 @@ Generate the layer of arithmetic functions of the ICN. """ function arithmetic_layer() arithmetics = LittleDict{Symbol, Function}( - :sum => _sum, - :prod => _prod, + :sum => _ar_sum, + :prod => _ar_prod, ) return Layer(arithmetics, true) diff --git a/test/layers.jl b/test/layers.jl index d02fc9c..3ed0661 100644 --- a/test/layers.jl +++ b/test/layers.jl @@ -97,12 +97,12 @@ for (f, results) in funcs_param, (key, vals) in enumerate(data) end # arithmetic layer -@test CN._sum(map(p -> p.first, data)) == [2, 7, 5, 6, 4] -@test CN._prod(map(p -> p.first, data)) == [1, 10, 6, 8, 3] +@test CN._ar_sum(map(p -> p.first, data)) == [2, 7, 5, 6, 4] +@test CN._ar_prod(map(p -> p.first, data)) == [1, 10, 6, 8, 3] # aggregation layer -@test CN._sum(data[1].first) == 15 -@test CN._sum(data[2].first) == 9 +@test CN._ag_sum(data[1].first) == 15 +@test CN._ag_sum(data[2].first) == 9 @test CN._count_positive(data[1].first) == 5 @test CN._count_positive(data[2].first) == 5 From 804ba558a8f41e1073196e8b431e70dd357bb795 Mon Sep 17 00:00:00 2001 From: azzaare Date: Wed, 6 Jan 2021 13:08:45 +0900 Subject: [PATCH 3/4] Renamed in comparison.jl --- src/comparison.jl | 12 ++++++------ src/io.jl | 4 ++-- test/layers.jl | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/comparison.jl b/src/comparison.jl index 033ee3b..790babe 100644 --- a/src/comparison.jl +++ b/src/comparison.jl @@ -12,8 +12,8 @@ _abs_diff_val_param(x::T, param::T) where T <: Number = abs(x - param) _param_minus_val(x::T, param::T) Return the difference `x - param` (resp. `param - x`) if positive, `0.0` otherwise. """ -_val_minus_param(x::T, param::T) where T <: Number = max(0.0, x - param) -_param_minus_val(x::T, param::T) where T <: Number = max(0.0, param - x) +_co_val_minus_param(x::T, param::T) where T <: Number = max(0.0, x - param) +_co_param_minus_val(x::T, param::T) where T <: Number = max(0.0, param - x) """ _euclidian_param(x::T, param::T, dom_size::T2) @@ -41,10 +41,10 @@ end Return the difference `x - nvars` (resp. `nvars - x`) if positive, `0.0` otherwise. """ function _val_minus_vars(x::T, nvars::Int) where {T <: Number} - return _val_minus_param(x, nvars) + return _co_val_minus_param(x, nvars) end function _vars_minus_val(x::T, nvars::Int) where {T <: Number} - return _param_minus_val(x, nvars) + return _co_param_minus_val(x, nvars) end """ @@ -63,8 +63,8 @@ function comparison_layer(nvars, dom_size, param = nothing) if !isnothing(param) comparisons_param = LittleDict{Symbol, Function}( :abs_diff_val_param => (x -> _abs_diff_val_param(x, param)), - :val_minus_param => (x -> _val_minus_param(x, param)), - :param_minus_val => (x -> _param_minus_val(x, param)), + :val_minus_param => (x -> _co_val_minus_param(x, param)), + :param_minus_val => (x -> _co_param_minus_val(x, param)), :euclidian_param => (x -> _euclidian_param(x, param, dom_size)), ) comparisons = LittleDict{Symbol, Function}(union(comparisons, comparisons_param)) diff --git a/src/io.jl b/src/io.jl index dc0477e..ff63902 100644 --- a/src/io.jl +++ b/src/io.jl @@ -1,5 +1,5 @@ -function csv2space(file; filter = :none) +function csv2space(file; filter=:none) df = DataFrame(CSV.File(file)) filter == :solutions && (df = df[df.concept .== true,:]) - return Vector(map(Vector,eachrow(df[!, Not(:concept)]))) + return Vector(map(Vector, eachrow(df[!, Not(:concept)]))) end diff --git a/test/layers.jl b/test/layers.jl index 3ed0661..061514f 100644 --- a/test/layers.jl +++ b/test/layers.jl @@ -122,8 +122,8 @@ end funcs_param = [ CN._abs_diff_val_param => [2, 5], - CN._val_minus_param => [2, 0], - CN._param_minus_val => [0, 5], + CN._co_val_minus_param => [2, 0], + CN._co_param_minus_val => [0, 5], ] for (f, results) in funcs_param, (key, vals) in enumerate(data) From 2d8cb436409ba38c57a545a1d4638585b4fdd64e Mon Sep 17 00:00:00 2001 From: azzaare Date: Wed, 6 Jan 2021 13:41:50 +0900 Subject: [PATCH 4/4] Untyping operations to handle x86 --- src/aggregation.jl | 4 +- src/comparison.jl | 42 ++++------- src/transformation.jl | 170 +++++++++++++++++------------------------- test/layers.jl | 56 +++++++------- 4 files changed, 115 insertions(+), 157 deletions(-) diff --git a/src/aggregation.jl b/src/aggregation.jl index a0fbf38..8f6bdff 100644 --- a/src/aggregation.jl +++ b/src/aggregation.jl @@ -8,7 +8,7 @@ _ag_sum(x) = reduce(+, x) _count_positive(x::V) Count the number of strictly positive elements of `x`. """ -_count_positive(x::V) where {T <: Number, V <: AbstractVector{T}} = count(y -> y > 0.0, x) +_ag_count_positive(x) = count(y -> y > 0.0, x) """ aggregation_layer() @@ -17,7 +17,7 @@ Generate the layer of aggregation functions of the ICN. function aggregation_layer() aggregations = LittleDict{Symbol, Function}( :sum => _ag_sum, - :count_positive => _count_positive, + :count_positive => _ag_count_positive, ) return Layer(aggregations, true) diff --git a/src/comparison.jl b/src/comparison.jl index 790babe..2154dfc 100644 --- a/src/comparison.jl +++ b/src/comparison.jl @@ -1,51 +1,41 @@ # doc in transformation.jl -_identity(x::T) where T <: Number = identity(x) +_co_identity(x) = identity(x) """ _abs_diff_val_param(x::T, param::T) Return the absolute difference between `x` and `param`. """ -_abs_diff_val_param(x::T, param::T) where T <: Number = abs(x - param) +_co_abs_diff_val_param(x, param) = abs(x - param) """ _val_minus_param(x::T, param::T) _param_minus_val(x::T, param::T) Return the difference `x - param` (resp. `param - x`) if positive, `0.0` otherwise. """ -_co_val_minus_param(x::T, param::T) where T <: Number = max(0.0, x - param) -_co_param_minus_val(x::T, param::T) where T <: Number = max(0.0, param - x) +_co_val_minus_param(x, param) = max(0.0, x - param) +_co_param_minus_val(x, param) = max(0.0, param - x) """ _euclidian_param(x::T, param::T, dom_size::T2) _euclidian(x::T, dom_size::T2) Compute an euclidian norm , possibly weigthed by `param`, on a scalar. """ -function _euclidian_param(x::T, param::T, dom_size::T2) where {T <: Number, T2 <: Number} - return x == param ? 0.0 : (1.0 + abs(x - param) \ dom_size) -end -function _euclidian(x::T, dom_size::T2) where {T <: Number, T2 <: Number} - return _euclidian_param(x, zero(T), dom_size) -end +_co_euclidian_param(x, param, d_size) = x == param ? 0.0 : (1.0 + abs(x - param) \ d_size) +_co_euclidian(x, d_size) = _co_euclidian_param(x, 0.0, d_size) """ _abs_diff_val_vars(x::T, nvars::Int) Return the absolute difference between `x` and the number of variables. """ -function _abs_diff_val_vars(x::T, nvars::Int) where {T <: Number} - return abs(x - nvars) -end +_co_abs_diff_val_vars(x, nvars) = abs(x - nvars) """ _val_minus_vars(x::T, nvars::Int) _vars_minus_val(x::T, nvars::Int) Return the difference `x - nvars` (resp. `nvars - x`) if positive, `0.0` otherwise. """ -function _val_minus_vars(x::T, nvars::Int) where {T <: Number} - return _co_val_minus_param(x, nvars) -end -function _vars_minus_val(x::T, nvars::Int) where {T <: Number} - return _co_param_minus_val(x, nvars) -end +_co_val_minus_vars(x, nvars) = _co_val_minus_param(x, nvars) +_co_vars_minus_val(x, nvars) = _co_param_minus_val(x, nvars) """ comparison_layer(nvars, dom_size, param = nothing) @@ -53,19 +43,19 @@ Generate the layer of transformations functions of the ICN. Iff `param` value is """ function comparison_layer(nvars, dom_size, param = nothing) comparisons = LittleDict{Symbol, Function}( - :identity => _identity, - :euclidian => (x -> _euclidian(x, dom_size)), - :abs_diff_val_vars => (x -> _abs_diff_val_vars(x, nvars)), - :val_minus_vars => (x -> _val_minus_vars(x, nvars)), - :vars_minus_val => (x -> _vars_minus_val(x, nvars)), + :identity => _co_identity, + :euclidian => (x -> _co_euclidian(x, dom_size)), + :abs_diff_val_vars => (x -> _co_abs_diff_val_vars(x, nvars)), + :val_minus_vars => (x -> _co_val_minus_vars(x, nvars)), + :vars_minus_val => (x -> _co_vars_minus_val(x, nvars)), ) if !isnothing(param) comparisons_param = LittleDict{Symbol, Function}( - :abs_diff_val_param => (x -> _abs_diff_val_param(x, param)), + :abs_diff_val_param => (x -> _co_abs_diff_val_param(x, param)), :val_minus_param => (x -> _co_val_minus_param(x, param)), :param_minus_val => (x -> _co_param_minus_val(x, param)), - :euclidian_param => (x -> _euclidian_param(x, param, dom_size)), + :euclidian_param => (x -> _co_euclidian_param(x, param, dom_size)), ) comparisons = LittleDict{Symbol, Function}(union(comparisons, comparisons_param)) end diff --git a/src/transformation.jl b/src/transformation.jl index 8c3af8e..1288dc0 100644 --- a/src/transformation.jl +++ b/src/transformation.jl @@ -1,120 +1,88 @@ """ - _identity(x::V) where {T <: Number,V <: AbstractVector{T}} - _identity(x::T) where T <: Number = identity(x) + _tr_identity(x::V) where {T <: Number,V <: AbstractVector{T}} + _tr_identity(x::T) where T <: Number = identity(x) Identity function. Already defined in Julia as `identity`, specialized for vectors and scalars. """ -_identity(x::V) where {T <: Number,V <: AbstractVector{T}} = identity(x) - -_identity(i::T, x::V) where {T <: Number,V <: AbstractVector{T}} = identity(i) +_tr_identity(x) = identity(x) +_tr_identity(i, x) = identity(i) """ - _count_eq(i::Int, x::V) - _count_eq_right(i::Int, x::V) - _count_eq_left(i::Int, x::V) + _tr_count_eq(i::Int, x::V) + _tr_count_eq_right(i::Int, x::V) + _tr_count_eq_left(i::Int, x::V) Count the number of elements equal to `x[i]` (optionally to the right/left of `x[i]`). Extended method to vector `x::V` are generated. """ -function _count_eq(i::Int, x::V) where {T <: Number,V <: AbstractVector{T}} - return count(y -> x[i] == y, x) - 1 -end -function _count_eq_right(i::Int, x::V) where {T <: Number,V <: AbstractVector{T}} - return _count_eq(1, @view x[i:end]) -end -function _count_eq_left(i::Int, x::V) where {T <: Number,V <: AbstractVector{T}} - return _count_eq(i, @view x[1:i]) -end +_tr_count_eq(i, x) = count(y -> x[i] == y, x) - 1 +_tr_count_eq_right(i, x) = _tr_count_eq(1, @view x[i:end]) +_tr_count_eq_left(i, x) = _tr_count_eq(i, @view x[1:i]) + # Generating vetorized versions -lazy(_count_eq, _count_eq_left, _count_eq_right) +lazy(_tr_count_eq, _tr_count_eq_left, _tr_count_eq_right) """ - _count_greater(i::Int, x::V) - _count_lesser(i::Int, x::V) - _count_g_left(i::Int, x::V) - _count_l_left(i::Int, x::V) - _count_g_right(i::Int, x::V) - _count_l_right(i::Int, x::V) + _tr_count_greater(i::Int, x::V) + _tr_count_lesser(i::Int, x::V) + _tr_count_g_left(i::Int, x::V) + _tr_count_l_left(i::Int, x::V) + _tr_count_g_right(i::Int, x::V) + _tr_count_l_right(i::Int, x::V) Count the number of elements greater/lesser than `x[i]` (optionally to the left/right of `x[i]`). Extended method to vector with sig `(x::V)` are generated. """ -function _count_greater(i::Int, x::V) where {T <: Number,V <: AbstractVector{T}} - return count(y -> x[i] < y, x) -end -function _count_lesser(i::Int, x::V) where {T <: Number,V <: AbstractVector{T}} - return count(y -> x[i] > y, x) -end -function _count_g_left(i::Int, x::V) where {T <: Number,V <: AbstractVector{T}} - return _count_greater(i, @view x[1:i]) -end -function _count_l_left(i::Int, x::V) where {T <: Number,V <: AbstractVector{T}} - return _count_lesser(i, @view x[1:i]) -end -function _count_g_right(i::Int, x::V) where {T <: Number,V <: AbstractVector{T}} - return _count_greater(1, @view x[i:end]) -end -function _count_l_right(i::Int, x::V) where {T <: Number,V <: AbstractVector{T}} - return _count_lesser(1, @view x[i:end]) -end +_tr_count_greater(i, x) = count(y -> x[i] < y, x) +_tr_count_lesser(i, x) = count(y -> x[i] > y, x) +_tr_count_g_left(i, x) = _tr_count_greater(i, @view x[1:i]) +_tr_count_l_left(i, x) = _tr_count_lesser(i, @view x[1:i]) +_tr_count_g_right(i, x) = _tr_count_greater(1, @view x[i:end]) +_tr_count_l_right(i, x) = _tr_count_lesser(1, @view x[i:end]) + # Generating vetorized versions -lazy(_count_greater, _count_g_left, _count_g_right) -lazy(_count_lesser, _count_l_left, _count_l_right) +lazy(_tr_count_greater, _tr_count_g_left, _tr_count_g_right) +lazy(_tr_count_lesser, _tr_count_l_left, _tr_count_l_right) """ - _count_eq_param(i::Int, x::V, param::T) - _count_l_param(i::Int, x::V, param::T) - _count_g_param(i::Int, x::V, param::T) + _tr_count_eq_param(i::Int, x::V, param::T) + _tr_count_l_param(i::Int, x::V, param::T) + _tr_count_g_param(i::Int, x::V, param::T) Count the number of elements equal to (resp. lesser/greater than) `x[i] + param`. Extended method to vector with sig `(x::V, param::T)` are generated. """ -function _count_eq_param(i::Int, x::V, param::T) where {T <: Number,V <: AbstractVector{T}} - return count(y -> y == x[i] + param, x) -end -function _count_l_param(i::Int, x::V, param::T) where {T <: Number,V <: AbstractVector{T}} - return count(y -> y < x[i] + param, x) -end -function _count_g_param(i::Int, x::V, param::T) where {T <: Number,V <: AbstractVector{T}} - return count(y -> y > x[i] + param, x) -end +_tr_count_eq_param(i, x, param) = count(y -> y == x[i] + param, x) +_tr_count_l_param(i, x, param) = count(y -> y < x[i] + param, x) +_tr_count_g_param(i, x, param) = count(y -> y > x[i] + param, x) + # Generating vetorized versions -lazy_param(_count_eq_param, _count_l_param, _count_g_param) +lazy_param(_tr_count_eq_param, _tr_count_l_param, _tr_count_g_param) """ - _count_bounding_param(i::Int, x::V, param::T) + _tr_count_bounding_param(i::Int, x::V, param::T) Count the number of elements bounded (not strictly) by `x[i]` and `x[i] + param`. An extended method to vector with sig `(x::V, param::T)` is generated. """ -function _count_bounding_param(i::Int, x::V, param::T -) where {T <: Number,V <: AbstractVector{T}} - return count(y -> x[i] ≤ y ≤ x[i] + param, x) -end +_tr_count_bounding_param(i, x, param) = count(y -> x[i] ≤ y ≤ x[i] + param, x) + # Generating vetorized versions -lazy_param(_count_bounding_param) +lazy_param(_tr_count_bounding_param) """ - _val_minus_param(i::Int, x::V, param::T) - _param_minus_val(i::Int, x::V, param::T) + _tr_val_minus_param(i::Int, x::V, param::T) + _tr_param_minus_val(i::Int, x::V, param::T) Return the difference `x[i] - param` (resp. `param - x[i]`) if positive, `0.0` otherwise. Extended method to vector with sig `(x::V, param::T)` are generated. """ -function _val_minus_param(i::Int, x::V, param::T -) where {T <: Number,V <: AbstractVector{T}} - return max(0, x[i] - param) -end -function _param_minus_val(i::Int, x::V, param::T -) where {T <: Number,V <: AbstractVector{T}} - return max(0, param - x[i]) -end +_tr_val_minus_param(i, x, param) = max(0, x[i] - param) +_tr_param_minus_val(i, x, param) = max(0, param - x[i]) + # Generating vetorized versions -lazy_param(_val_minus_param, _param_minus_val) +lazy_param(_tr_val_minus_param, _tr_param_minus_val) """ - _contiguous_vals_minus(i::Int, x::V) - _contiguous_vals_minus_rev(i::Int, x::V) + _tr_contiguous_vals_minus(i::Int, x::V) + _tr_contiguous_vals_minus_rev(i::Int, x::V) Return the difference `x[i] - x[i + 1]` (resp. `x[i + 1] - x[i]`) if positive, `0.0` otherwise. Extended method to vector with sig `(x::V)` are generated. """ -function _contiguous_vals_minus(i::Int, x::V) where {T <: Number,V <: AbstractVector{T}} - return length(x) == i ? 0 : _val_minus_param(i, x, x[i + 1]) -end -function _contiguous_vals_minus_rev(i::Int, x::V -) where {T <: Number,V <: AbstractVector{T}} - return length(x) == i ? 0 : _param_minus_val(i, x, x[i + 1]) +_tr_contiguous_vals_minus(i, x) = length(x) == i ? 0 : _tr_val_minus_param(i, x, x[i + 1]) +function _tr_contiguous_vals_minus_rev(i, x) + return length(x) == i ? 0 : _tr_param_minus_val(i, x, x[i + 1]) end # Generating vetorized versions -lazy(_contiguous_vals_minus, _contiguous_vals_minus_rev) +lazy(_tr_contiguous_vals_minus, _tr_contiguous_vals_minus_rev) """ @@ -123,28 +91,28 @@ Generate the layer of transformations functions of the ICN. Iff `param` value is """ function transformation_layer(param = nothing) transformations = LittleDict{Symbol, Function}( - :identity => _identity, - :count_eq => _count_eq, - :count_eq_left => _count_eq_left, - :count_eq_right => _count_eq_right, - :count_greater => _count_greater, - :count_lesser => _count_lesser, - :count_g_left => _count_g_left, - :count_l_left => _count_l_left, - :count_g_right => _count_g_right, - :count_l_right => _count_l_right, - :contiguous_vals_minus => _contiguous_vals_minus, - :contiguous_vals_minus_rev => _contiguous_vals_minus_rev, + :identity => _tr_identity, + :count_eq => _tr_count_eq, + :count_eq_left => _tr_count_eq_left, + :count_eq_right => _tr_count_eq_right, + :count_greater => _tr_count_greater, + :count_lesser => _tr_count_lesser, + :count_g_left => _tr_count_g_left, + :count_l_left => _tr_count_l_left, + :count_g_right => _tr_count_g_right, + :count_l_right => _tr_count_l_right, + :contiguous_vals_minus => _tr_contiguous_vals_minus, + :contiguous_vals_minus_rev => _tr_contiguous_vals_minus_rev, ) if !isnothing(param) transformations_param = LittleDict{Symbol, Function}( - :count_eq_param => ((x...) -> _count_eq_param(x..., param)), - :count_l_param => ((x...) -> _count_l_param(x..., param)), - :count_g_param => ((x...) -> _count_g_param(x..., param)), - :count_bounding_param => ((x...) -> _count_bounding_param(x..., param)), - :val_minus_param => ((x...) -> _val_minus_param(x..., param)), - :param_minus_val => ((x...) -> _param_minus_val(x..., param)), + :count_eq_param => ((x...) -> _tr_count_eq_param(x..., param)), + :count_l_param => ((x...) -> _tr_count_l_param(x..., param)), + :count_g_param => ((x...) -> _tr_count_g_param(x..., param)), + :count_bounding_param => ((x...) -> _tr_count_bounding_param(x..., param)), + :val_minus_param => ((x...) -> _tr_val_minus_param(x..., param)), + :param_minus_val => ((x...) -> _tr_param_minus_val(x..., param)), ) transformations = LittleDict(union(transformations, transformations_param)) end diff --git a/test/layers.jl b/test/layers.jl index 061514f..a31014e 100644 --- a/test/layers.jl +++ b/test/layers.jl @@ -6,51 +6,51 @@ data = [ # Test transformations without parameters funcs = Dict( - CN._identity => [ + CN._tr_identity => [ data[1].first, data[2].first, ], - CN._count_eq => [ + CN._tr_count_eq => [ [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], ], - CN._count_eq_right => [ + CN._tr_count_eq_right => [ [0, 0, 0, 0, 0], [1, 1, 0, 0, 0], ], - CN._count_eq_left => [ + CN._tr_count_eq_left => [ [0, 0, 0, 0, 0], [0, 0, 0, 1, 1], ], - CN._count_greater => [ + CN._tr_count_greater => [ [4, 0, 3, 1, 2], [3, 1, 0, 1, 3], ], - CN._count_lesser => [ + CN._tr_count_lesser => [ [0, 4, 1, 3, 2], [0, 2, 4, 2, 0], ], - CN._count_g_left => [ + CN._tr_count_g_left => [ [0, 0, 1, 1, 2], [0, 0, 0, 1, 3], ], - CN._count_l_left => [ + CN._tr_count_l_left => [ [0, 1, 1, 2, 2], [0, 1, 2, 1, 0], ], - CN._count_g_right => [ + CN._tr_count_g_right => [ [4, 0, 2, 0, 0], [3, 1, 0, 0, 0], ], - CN._count_l_right => [ + CN._tr_count_l_right => [ [0, 3, 0, 1, 0], [0, 1, 2, 1, 0], ], - CN._contiguous_vals_minus => [ + CN._tr_contiguous_vals_minus => [ [0, 3, 0, 1, 0], [0, 0, 1, 1, 0], ], - CN._contiguous_vals_minus_rev => [ + CN._tr_contiguous_vals_minus_rev => [ [4, 0, 2, 0, 0], [1, 1, 0, 0, 0], ], @@ -64,27 +64,27 @@ end # Test transformations with parameter funcs_param = Dict( - CN._count_eq_param => [ + CN._tr_count_eq_param => [ [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], ], - CN._count_l_param => [ + CN._tr_count_l_param => [ [2, 5, 3, 5, 4], [4, 5, 5, 5, 4], ], - CN._count_g_param => [ + CN._tr_count_g_param => [ [2, 0, 1, 0, 0], [0, 0, 0, 0, 0], ], - CN._count_bounding_param => [ + CN._tr_count_bounding_param => [ [3, 1, 3, 2, 3], [5, 3, 1, 3, 5], ], - CN._val_minus_param => [ + CN._tr_val_minus_param => [ [0, 3, 0, 2, 1], [0, 0, 1, 0, 0], ], - CN._param_minus_val => [ + CN._tr_param_minus_val => [ [1, 0, 0, 0, 0], [1, 0, 0, 0, 1], ], @@ -104,15 +104,15 @@ end @test CN._ag_sum(data[1].first) == 15 @test CN._ag_sum(data[2].first) == 9 -@test CN._count_positive(data[1].first) == 5 -@test CN._count_positive(data[2].first) == 5 -@test CN._count_positive([1, 0, 1, 0, 1]) == 3 +@test CN._ag_count_positive(data[1].first) == 5 +@test CN._ag_count_positive(data[2].first) == 5 +@test CN._ag_count_positive([1, 0, 1, 0, 1]) == 3 # Comparison layer data = [3 => (1, 5), 5 => (10, 5)] funcs = [ - CN._identity => [3, 5], + CN._co_identity => [3, 5], ] # test no param/vars @@ -121,7 +121,7 @@ for (f, results) in funcs, (key, vals) in enumerate(data) end funcs_param = [ - CN._abs_diff_val_param => [2, 5], + CN._co_abs_diff_val_param => [2, 5], CN._co_val_minus_param => [2, 0], CN._co_param_minus_val => [0, 5], ] @@ -131,9 +131,9 @@ for (f, results) in funcs_param, (key, vals) in enumerate(data) end funcs_vars = [ - CN._abs_diff_val_vars => [2, 0], - CN._val_minus_vars => [0, 0], - CN._vars_minus_val => [2, 0], + CN._co_abs_diff_val_vars => [2, 0], + CN._co_val_minus_vars => [0, 0], + CN._co_vars_minus_val => [2, 0], ] for (f, results) in funcs_vars, (key, vals) in enumerate(data) @@ -142,7 +142,7 @@ end funcs_param_dom = [ - CN._euclidian_param => [3.5, 2.0], + CN._co_euclidian_param => [3.5, 2.0], ] for (f, results) in funcs_param_dom, (key, vals) in enumerate(data) @@ -150,7 +150,7 @@ for (f, results) in funcs_param_dom, (key, vals) in enumerate(data) end funcs_dom = [ - CN._euclidian => [8/3, 2.0], + CN._co_euclidian => [8/3, 2.0], ] for (f, results) in funcs_dom, (key, vals) in enumerate(data)