File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -1546,9 +1546,7 @@ function _add_to_quadratic!(
15461546 scale:: T ,
15471547 f:: MOI.ScalarAffineTerm{S} ,
15481548) where {T<: Real ,S}
1549- if promote_type (T, S) != T
1550- return # We can't store `S` in `T`.
1551- end
1549+ @assert promote_type (T, S) == T
15521550 push! (
15531551 ret. affine_terms,
15541552 MOI. ScalarAffineTerm {T} (scale * f. coefficient, f. variable),
@@ -1561,9 +1559,7 @@ function _add_to_quadratic!(
15611559 scale:: T ,
15621560 f:: MOI.ScalarQuadraticTerm{S} ,
15631561) where {T<: Real ,S}
1564- if promote_type (T, S) != T
1565- return # We can't store `S` in `T`.
1566- end
1562+ @assert promote_type (T, S) == T
15671563 push! (
15681564 ret. quadratic_terms,
15691565 MOI. ScalarQuadraticTerm {T} (
Original file line number Diff line number Diff line change @@ -406,6 +406,14 @@ function test_simplify_VectorNonlinearFunction()
406406 return
407407end
408408
409+ function test_simplify_VectorNonlinearFunction_abstract ()
410+ x = MOI. VariableIndex (1 )
411+ f = MOI. VectorNonlinearFunction ([x, 1.0 * x, op (:sin , x)])
412+ g = MOI. VectorNonlinearFunction ([x, x, op (:sin , x)])
413+ @test SymbolicAD. simplify (f) ≈ g
414+ return
415+ end
416+
409417function test_simplify_deep ()
410418 N = 10_000
411419 x = MOI. VariableIndex .(1 : N)
@@ -753,6 +761,7 @@ function test_simplify_if_quadratic()
753761 op (:+ , big (1 ) * x * x, big (2 ))=> nothing ,
754762 op (:+ , big (1 ) * x, big (2 ))=> nothing ,
755763 op (:+ , x, big (2 ))=> nothing ,
764+ op (:+ , x, 1 + 2im )=> nothing ,
756765 ]
757766 @test SymbolicAD. _simplify_if_quadratic! (f) ≈ something (ret, f)
758767 end
You can’t perform that action at this time.
0 commit comments