Skip to content

Commit a89d22f

Browse files
committed
ci: more test coverage cleanup
1 parent 564d3b3 commit a89d22f

13 files changed

+33
-28
lines changed

src/Evaluate.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function Base.copy(buffer::ArrayBuffer)
4242
end
4343

4444
reset_index!(buffer::ArrayBuffer) = buffer.index[] = 0
45-
reset_index!(::Nothing) = nothing
45+
reset_index!(::Nothing) = nothing # COV_EXCL_LINE
4646

4747
next_index!(buffer::ArrayBuffer) = buffer.index[] += 1
4848

@@ -373,7 +373,7 @@ end
373373
nops = get_nops(O, Val(degree))
374374
return quote
375375
cs = get_children(tree, Val($degree))
376-
Base.Cartesian.@nexprs(
376+
Base.Cartesian.@nexprs( # COV_EXCL_LINE
377377
$degree,
378378
i -> begin # COV_EXCL_LINE
379379
result_i = _eval_tree_array(cs[i], cX, operators, eval_options)
@@ -867,7 +867,7 @@ end
867867
nops = get_nops(operators, Val(degree))
868868
quote
869869
cs = get_children(tree, Val($degree))
870-
Base.Cartesian.@nexprs(
870+
Base.Cartesian.@nexprs( # COV_EXCL_LINE
871871
$degree,
872872
i -> begin # COV_EXCL_LINE
873873
cumulator_i =

src/EvaluateDerivative.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ end
129129

130130
setup = quote
131131
cs = get_children(tree, Val($degree))
132-
Base.Cartesian.@nexprs(
132+
Base.Cartesian.@nexprs( # COV_EXCL_LINE
133133
$degree,
134134
i -> begin # COV_EXCL_LINE
135135
result_i = _eval_diff_tree_array(cs[i], cX, operators, direction)
@@ -295,7 +295,7 @@ end
295295
cs = get_children(tree, Val($degree))
296296
index_cs =
297297
isnothing(index_tree) ? index_tree : get_children(index_tree, Val($degree))
298-
Base.Cartesian.@nexprs(
298+
Base.Cartesian.@nexprs( # COV_EXCL_LINE
299299
$degree,
300300
i -> begin # COV_EXCL_LINE
301301
result_i = eval_grad_tree_array(

src/EvaluationHelpers.jl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
module EvaluationHelpersModule
22

3-
using ChainRulesCore: @non_differentiable
4-
53
import Base: adjoint
64
import ..OperatorEnumModule: AbstractOperatorEnum, OperatorEnum, GenericOperatorEnum
75
import ..NodeModule: AbstractExpressionNode
86
import ..EvaluateModule: eval_tree_array
97
import ..EvaluateDerivativeModule: eval_grad_tree_array
10-
11-
function _set_nan!(out)
12-
out .= convert(eltype(out), NaN)
13-
return nothing
14-
end
8+
import ..UtilsModule: set_nan!
159

1610
# Evaluation:
1711
"""
@@ -34,7 +28,7 @@ and triplets of operations for lower memory usage.
3428
"""
3529
function (tree::AbstractExpressionNode)(X, operators::OperatorEnum; kws...)
3630
out, did_finish = eval_tree_array(tree, X, operators; kws...)
37-
!did_finish && _set_nan!(out)
31+
!did_finish && set_nan!(out)
3832
return out
3933
end
4034
"""
@@ -63,7 +57,7 @@ function _grad_evaluator(
6357
tree::AbstractExpressionNode, X, operators::OperatorEnum; variable=Val(true), kws...
6458
)
6559
_, grad, did_complete = eval_grad_tree_array(tree, X, operators; variable, kws...)
66-
!did_complete && _set_nan!(grad)
60+
!did_complete && set_nan!(grad)
6761
return grad
6862
end
6963
function _grad_evaluator(

src/NodePreallocation.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ function copy_into!(
4949
N,
5050
)
5151
end
52-
# COV_EXCL_START
5352
function leaf_copy_into!(dest::N, src::N) where {N<:AbstractExpressionNode}
5453
set_node!(dest, src)
5554
return dest
5655
end
57-
# COV_EXCL_STOP
5856
function branch_copy_into!(
5957
dest::N, src::N, children::Vararg{Any,M}
6058
) where {T,D,N<:AbstractExpressionNode{T,D},M}

src/NodeUtils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ end
179179

180180
# Sharing is never needed for NodeIndex,
181181
# as we trace over the node we are indexing on.
182-
preserve_sharing(::Union{Type{<:NodeIndex},NodeIndex}) = false
182+
preserve_sharing(::Union{Type{<:NodeIndex},NodeIndex}) = false # COV_EXCL_LINE
183183

184184
function index_constant_nodes(
185185
tree::AbstractExpressionNode{Ti,D} where {Ti}, ::Type{T}=UInt16
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
module NonDifferentiableDeclarationsModule
22

3+
# COV_EXCL_START
4+
35
using ChainRulesCore: @non_differentiable
6+
import ..UtilsModule: set_nan!
47
import ..OperatorEnumModule: AbstractOperatorEnum
58
import ..NodeModule: AbstractExpressionNode, AbstractNode
69
import ..NodeUtilsModule: tree_mapreduce
710
import ..ExpressionModule:
811
AbstractExpression, get_operators, get_variable_names, _validate_input
9-
import ..EvaluationHelpersModule: _set_nan!
1012

1113
#! format: off
1214
@non_differentiable tree_mapreduce(f::Function, op::Function, tree::AbstractNode, result_type::Type)
1315
@non_differentiable tree_mapreduce(f::Function, f_branch::Function, op::Function, tree::AbstractNode, result_type::Type)
1416
@non_differentiable get_operators(ex::Union{AbstractExpression,AbstractExpressionNode}, operators::Union{AbstractOperatorEnum,Nothing})
1517
@non_differentiable get_variable_names(ex::AbstractExpression, variable_names::Union{AbstractVector{<:AbstractString},Nothing})
1618
@non_differentiable _validate_input(ex::AbstractExpression, X, operators::Union{AbstractOperatorEnum,Nothing})
17-
@non_differentiable _set_nan!(::Any)
19+
@non_differentiable set_nan!(::Any)
1820
#! format: on
1921

22+
# COV_EXCL_STOP
23+
2024
end

src/OperatorEnumConstruction.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function _extend_operators(operators, skip_user_operators, kws, __module__::Modu
318318

319319
#! format: off
320320
return quote
321-
local $type_requirements, $build_converters, $op_exists
321+
local $type_requirements, $build_converters, $op_exists # COV_EXCL_LINE
322322
$(_validate_no_ambiguous_broadcasts)($operators)
323323
lock($LATEST_LOCK)
324324
try

src/ParametricExpression.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using ..NodeModule: AbstractExpressionNode, Node, tree_mapreduce
88
using ..ExpressionModule:
99
AbstractExpression, Metadata, with_contents, with_metadata, unpack_metadata
1010
using ..ChainRulesModule: NodeTangent
11-
using ..UtilsModule: Nullable
11+
using ..UtilsModule: Nullable, set_nan!
1212

1313
import ..NodeModule:
1414
constructorof,
@@ -125,7 +125,7 @@ end
125125
function default_node_type(::Type{N}) where {T,N<:ParametricExpression{T}}
126126
return ParametricNode{T,max_degree(N)}
127127
end
128-
preserve_sharing(::Union{Type{<:ParametricNode},ParametricNode}) = false # TODO: Change this?
128+
preserve_sharing(::Union{Type{<:ParametricNode},ParametricNode}) = false # COV_EXCL_LINE
129129
function leaf_copy(t::ParametricNode{T}) where {T}
130130
if t.constant
131131
return constructorof(typeof(t))(; val=t.val)
@@ -368,9 +368,7 @@ function (ex::ParametricExpression)(
368368
kws...,
369369
) where {T}
370370
(output, flag) = eval_tree_array(ex, X, classes, operators; kws...)
371-
if !flag
372-
output .= NaN
373-
end
371+
!flag && set_nan!(output)
374372
return output
375373
end
376374
function eval_tree_array(

src/Simplify.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import ..ValueInterfaceModule: is_valid
1010

1111
@inline _op_kernel(f::F, l::T, ls::T...) where {F,T} = f(l, ls...)
1212

13+
# COV_EXCL_START
1314
is_commutative(::typeof(*)) = true
1415
is_commutative(::typeof(+)) = true
1516
is_commutative(_) = false
1617

1718
is_subtraction(::typeof(-)) = true
1819
is_subtraction(_) = false
20+
# COV_EXCL_STOP
1921

2022
combine_operators(tree::AbstractExpressionNode, ::AbstractOperatorEnum) = tree
2123
# This is only defined for `Node` as it is not possible for, e.g.,

src/Strings.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function get_pretty_op_name(op::F) where {F}
7373
return get_op_name(op)
7474
end
7575

76-
@inline function strip_brackets(s::Vector{Char})::Vector{Char}
76+
@inline function strip_brackets(s::Vector{Char})
7777
if first(s) == '(' && last(s) == ')'
7878
return s[(begin + 1):(end - 1)]
7979
else

0 commit comments

Comments
 (0)