| 
1 | 1 | using ModelingToolkit, NonlinearSolve, SymbolicIndexingInterface  | 
 | 2 | +import ModelingToolkit as MTK  | 
2 | 3 | using LinearAlgebra  | 
3 | 4 | using Test  | 
 | 5 | + | 
 | 6 | +@testset "Safe HCProblem" begin  | 
 | 7 | +    @variables x y z  | 
 | 8 | +    eqs = [0 ~ x^2 + y^2 + 2x * y  | 
 | 9 | +           0 ~ x^2 + 4x + 4  | 
 | 10 | +           0 ~ y * z + 4x^2]  | 
 | 11 | +    @mtkbuild sys = NonlinearSystem(eqs)  | 
 | 12 | +    prob = MTK.safe_HomotopyContinuationProblem(sys, [x => 1.0, y => 1.0, z => 1.0], [])  | 
 | 13 | +    @test prob === nothing  | 
 | 14 | +end  | 
 | 15 | + | 
 | 16 | + | 
4 | 17 | import HomotopyContinuation  | 
5 | 18 | 
 
  | 
6 | 19 | @testset "No parameters" begin  | 
 | 
78 | 91 |     @test_throws ["Cannot convert", "Unable", "symbolically solve",  | 
79 | 92 |         "Exponent", "not an integer", "not a polynomial"] HomotopyContinuationProblem(  | 
80 | 93 |         sys, [])  | 
 | 94 | +    @test MTK.safe_HomotopyContinuationProblem(sys, []) isa MTK.NotPolynomialError  | 
81 | 95 |     @mtkbuild sys = NonlinearSystem([x^x - x ~ 0])  | 
82 | 96 |     @test_throws ["Cannot convert", "Unable", "symbolically solve",  | 
83 | 97 |         "Exponent", "unknowns", "not a polynomial"] HomotopyContinuationProblem(  | 
84 | 98 |         sys, [])  | 
 | 99 | +    @test MTK.safe_HomotopyContinuationProblem(sys, []) isa MTK.NotPolynomialError  | 
85 | 100 |     @mtkbuild sys = NonlinearSystem([((x^2) / sin(x))^2 + x ~ 0])  | 
86 | 101 |     @test_throws ["Cannot convert", "both polynomial", "non-polynomial",  | 
87 | 102 |         "recognized", "sin", "not a polynomial"] HomotopyContinuationProblem(  | 
88 | 103 |         sys, [])  | 
 | 104 | +    @test MTK.safe_HomotopyContinuationProblem(sys, []) isa MTK.NotPolynomialError  | 
89 | 105 | 
 
  | 
90 | 106 |     @variables y = 2.0  | 
91 | 107 |     @mtkbuild sys = NonlinearSystem([x^2 + y^2 + 2 ~ 0, y ~ sin(x)])  | 
92 | 108 |     @test_throws ["Cannot convert", "recognized", "sin", "not a polynomial"] HomotopyContinuationProblem(  | 
93 | 109 |         sys, [])  | 
 | 110 | +    @test MTK.safe_HomotopyContinuationProblem(sys, []) isa MTK.NotPolynomialError  | 
94 | 111 | 
 
  | 
95 | 112 |     @mtkbuild sys = NonlinearSystem([x^2 + y^2 - 2 ~ 0, sin(x + y) ~ 0])  | 
96 | 113 |     @test_throws ["Cannot convert", "function of multiple unknowns"] HomotopyContinuationProblem(  | 
97 | 114 |         sys, [])  | 
 | 115 | +    @test MTK.safe_HomotopyContinuationProblem(sys, []) isa MTK.NotPolynomialError  | 
98 | 116 | 
 
  | 
99 | 117 |     @mtkbuild sys = NonlinearSystem([sin(x)^2 + 1 ~ 0, cos(y) - cos(x) - 1 ~ 0])  | 
100 | 118 |     @test_throws ["Cannot convert", "multiple non-polynomial terms", "same unknown"] HomotopyContinuationProblem(  | 
101 | 119 |         sys, [])  | 
 | 120 | +    @test MTK.safe_HomotopyContinuationProblem(sys, []) isa MTK.NotPolynomialError  | 
102 | 121 | 
 
  | 
103 | 122 |     @mtkbuild sys = NonlinearSystem([sin(x^2)^2 + sin(x^2) - 1 ~ 0])  | 
104 | 123 |     @test_throws ["import Nemo"] HomotopyContinuationProblem(sys, [])  | 
 | 124 | +    @test MTK.safe_HomotopyContinuationProblem(sys, []) isa MTK.NotPolynomialError  | 
105 | 125 | end  | 
106 | 126 | 
 
  | 
107 | 127 | import Nemo  | 
 | 
0 commit comments