File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 185185
186186@testitem " ValidVector operations with Union{} return type" tags = [:part2 ] begin
187187 using SymbolicRegression: ValidVector
188- using SymbolicRegression. ComposableExpressionModule: apply_operator
188+ using SymbolicRegression. ComposableExpressionModule: apply_operator, _match_eltype
189189
190190 error_op (:: Any , :: Any ) = error (" This should cause Union{} inference" )
191191
201201 b = 1.0
202202 result2 = apply_operator (* , a, b)
203203 @test result2 isa ValidVector{<: AbstractArray{Float64} }
204+
205+ # Test apply_operator when all inputs are valid
206+ valid_x = ValidVector ([1.0 , 2.0 ], true )
207+ valid_y = ValidVector ([3.0 , 4.0 ], true )
208+ valid_result = apply_operator (+ , valid_x, valid_y)
209+ @test valid_result. valid == true
210+ @test valid_result. x ≈ [4.0 , 6.0 ]
211+
212+ # cover _match_eltype
213+ arr = [1.0 , 2.0 ]
214+ @test _match_eltype (ValidVector{Vector{Float64}}, arr) === arr # Same type
215+ arr_f32 = Float32[1.0 , 2.0 ]
216+ @test _match_eltype (ValidVector{Vector{Float64}}, arr_f32) isa Vector{Float64} # Different type
204217end
Original file line number Diff line number Diff line change 696696@testitem " Test Float32/Float64 type conversion in TemplateExpression" tags = [:part2 ] begin
697697 using SymbolicRegression
698698 using SymbolicRegression: eval_loss
699+ using SymbolicRegression. TemplateExpressionModule: _match_input_eltype
699700
700701 template = @template_spec (expressions = (f,)) do x1, x2
701702 0.5 * f (x1, x2) # 0.5 is Float64 literal
719720 loss = eval_loss (template_expr, dataset, options)
720721 @test loss isa Float32
721722 @test loss ≈ 0.0
723+
724+ # Test _match_input_eltype coverage (covers lines 675-676)
725+ result_f64 = [1.0 , 2.0 ]
726+ @test _match_input_eltype (Matrix{Float64}, result_f64) === result_f64 # Same type
727+ result_int = [1 , 2 ]
728+ @test _match_input_eltype (Matrix{Float64}, result_int) === result_int # Non-float type
722729end
You can’t perform that action at this time.
0 commit comments