@@ -75,17 +75,17 @@ function test_extension_expression(
7575 @test string (@expression (model, sin (x))) == " sin(x)"
7676 @test string (@expression (model, ifelse (x >= 0 , x, 0 ))) ==
7777 " ifelse(x >= 0, x, 0)"
78- @test string (@expression (model, 2 ^ x)) == " 2.0 ^ x"
78+ @test string (@expression (model, 2 ^ x)) == " 2 ^ x"
7979 @test string (@expression (model, x^ x)) == " x ^ x"
80- @test string (@expression (model, sin (x)^ 2 )) == " sin(x) ^ 2.0 "
81- @test string (@expression (model, sin (x)^ 2.0 )) == " sin(x) ^ 2.0 "
82- @test string (@expression (model, 2 * sin (x)^ 2.0 )) == " 2.0 * (sin(x) ^ 2.0 )"
83- @test string (@expression (model, 1 + sin (x))) == " 1.0 + sin(x)"
84- @test string (@expression (model, 1 + 2 * sin (x))) == " 1.0 + (2.0 * sin(x))"
80+ @test string (@expression (model, sin (x)^ 2 )) == " sin(x) ^ 2"
81+ @test string (@expression (model, sin (x)^ 2.0 )) == " sin(x) ^ 2"
82+ @test string (@expression (model, 2 * sin (x)^ 2.0 )) == " 2 * (sin(x) ^ 2)"
83+ @test string (@expression (model, 1 + sin (x))) == " 1 + sin(x)"
84+ @test string (@expression (model, 1 + 2 * sin (x))) == " 1 + (2 * sin(x))"
8585 @test string (@expression (model, 2.0 * sin (x)^ 2 + cos (x) / x)) ==
86- " (2.0 * (sin(x) ^ 2.0 )) + (cos(x) / x)"
86+ " (2 * (sin(x) ^ 2)) + (cos(x) / x)"
8787 @test string (@expression (model, 2.0 * sin (x)^ 2 - cos (x) / x)) ==
88- " (2.0 * (sin(x) ^ 2.0 )) - (cos(x) / x)"
88+ " (2 * (sin(x) ^ 2)) - (cos(x) / x)"
8989 return
9090end
9191
@@ -99,8 +99,8 @@ function test_extension_flatten_nary(
9999 expr_mult = GenericNonlinearExpr {VariableRefType} (:* , Any[x])
100100 expr_sin = GenericNonlinearExpr {VariableRefType} (:sin , Any[x])
101101 to_string (x) = string (flatten! (x))
102- @test to_string (+ (expr_plus, 1 )) == " x + 1.0 "
103- @test to_string (+ (1 , expr_plus)) == " 1.0 + x"
102+ @test to_string (+ (expr_plus, 1 )) == " x + 1"
103+ @test to_string (+ (1 , expr_plus)) == " 1 + x"
104104 @test to_string (+ (expr_plus, x)) == " x + x"
105105 @test to_string (+ (expr_sin, x)) == " sin(x) + x"
106106 @test to_string (+ (x, expr_plus)) == " x + x"
@@ -109,8 +109,8 @@ function test_extension_flatten_nary(
109109 @test to_string (+ (expr_plus, expr_sin)) == " x + sin(x)"
110110 @test to_string (+ (expr_sin, expr_plus)) == " sin(x) + x"
111111 @test to_string (+ (expr_sin, expr_sin)) == " sin(x) + sin(x)"
112- @test to_string (* (expr_mult, 2 )) == " x * 2.0 "
113- @test to_string (* (2 , expr_mult)) == " 2.0 * x"
112+ @test to_string (* (expr_mult, 2 )) == " x * 2"
113+ @test to_string (* (2 , expr_mult)) == " 2 * x"
114114 @test to_string (* (expr_mult, x)) == " x * x"
115115 @test to_string (* (expr_sin, x)) == " sin(x) * x"
116116 @test to_string (* (x, expr_mult)) == " x * x"
@@ -119,7 +119,7 @@ function test_extension_flatten_nary(
119119 @test to_string (* (expr_mult, expr_sin)) == " x * sin(x)"
120120 @test to_string (* (expr_sin, expr_mult)) == " sin(x) * x"
121121 @test to_string (* (expr_sin, expr_sin)) == " sin(x) * sin(x)"
122- @test to_string (sin (+ (expr_plus, 1 ))) == " sin(x + 1.0 )"
122+ @test to_string (sin (+ (expr_plus, 1 ))) == " sin(x + 1)"
123123 @test to_string (sin (* (expr_mult, expr_mult))) == " sin(x * x)"
124124 return
125125end
@@ -128,8 +128,8 @@ function test_extension_zero_one(
128128 ModelType = Model,
129129 VariableRefType = VariableRef,
130130)
131- @test string (zero (GenericNonlinearExpr{VariableRefType})) == " +(0.0 )"
132- @test string (one (GenericNonlinearExpr{VariableRefType})) == " +(1.0 )"
131+ @test string (zero (GenericNonlinearExpr{VariableRefType})) == " +(0)"
132+ @test string (one (GenericNonlinearExpr{VariableRefType})) == " +(1)"
133133 return
134134end
135135
@@ -151,7 +151,7 @@ function test_extension_latex(ModelType = Model, VariableRefType = VariableRef)
151151
152152 @expression (model, g, ifelse (x > 0 , sin (x), x + cos (x)^ 2 ))
153153 @test function_string (MIME (" text/latex" ), g) ==
154- raw " \t extsf{ifelse}\l eft({{x} > {0}}, {\t extsf{sin}\l eft({x}\r ight)}, {{x} + {\l eft({\t extsf{cos}\l eft({x}\r ight)} ^ {2.0 }\r ight)}}\r ight)"
154+ raw " \t extsf{ifelse}\l eft({{x} > {0}}, {\t extsf{sin}\l eft({x}\r ight)}, {{x} + {\l eft({\t extsf{cos}\l eft({x}\r ight)} ^ {2}\r ight)}}\r ight)"
155155 return
156156end
157157
@@ -178,13 +178,13 @@ function test_extension_expression_addmul(
178178)
179179 model = ModelType ()
180180 @variable (model, x)
181- @test string (@expression (model, x + 3 * sin (x))) == " x + (3.0 * sin(x))"
181+ @test string (@expression (model, x + 3 * sin (x))) == " x + (3 * sin(x))"
182182 @test string (@expression (model, 2 * x + 3 * sin (x))) ==
183- " (2 x) + (3.0 * sin(x))"
183+ " (2 x) + (3 * sin(x))"
184184 @test string (@expression (model, x^ 2 + 3 * sin (x))) ==
185- " ($(x^ 2 ) ) + (3.0 * sin(x))"
185+ " ($(x^ 2 ) ) + (3 * sin(x))"
186186 @test string (@expression (model, sin (x) + 3 * sin (x))) ==
187- " sin(x) + (3.0 * sin(x))"
187+ " sin(x) + (3 * sin(x))"
188188 @test string (@expression (model, sin (x) + 3 * x)) == " sin(x) + (3 x)"
189189 @test string (@expression (model, sin (x) + 3 * x * x)) ==
190190 " sin(x) + (3 $(x^ 2 ) )"
@@ -198,11 +198,11 @@ function test_extension_expression_explicit_add_mul(
198198 model = ModelType ()
199199 @variable (model, x)
200200 f = sin (x)
201- @test string (MA. operate!! (MA. add_mul, 1 , 2 , f)) == " 1.0 + (2.0 * $f )"
202- @test string (MA. operate!! (MA. add_mul, 1 , f, 2 )) == " 1.0 + ($f * 2.0 )"
203- @test string (MA. operate!! (MA. add_mul, 1 , f, f)) == " 1.0 + ($f * $f )"
204- @test string (MA. operate!! (MA. add_mul, f, 2 , f)) == " $f + (2.0 * $f )"
205- @test string (MA. operate!! (MA. add_mul, f, f, 2 )) == " $f + ($f * 2.0 )"
201+ @test string (MA. operate!! (MA. add_mul, 1 , 2 , f)) == " 1 + (2 * $f )"
202+ @test string (MA. operate!! (MA. add_mul, 1 , f, 2 )) == " 1 + ($f * 2)"
203+ @test string (MA. operate!! (MA. add_mul, 1 , f, f)) == " 1 + ($f * $f )"
204+ @test string (MA. operate!! (MA. add_mul, f, 2 , f)) == " $f + (2 * $f )"
205+ @test string (MA. operate!! (MA. add_mul, f, f, 2 )) == " $f + ($f * 2)"
206206 @test string (MA. operate!! (MA. add_mul, f, f, f)) == " $f + ($f * $f )"
207207 return
208208end
@@ -213,13 +213,13 @@ function test_extension_expression_submul(
213213)
214214 model = ModelType ()
215215 @variable (model, x)
216- @test string (@expression (model, x - 3 * sin (x))) == " x - (3.0 * sin(x))"
216+ @test string (@expression (model, x - 3 * sin (x))) == " x - (3 * sin(x))"
217217 @test string (@expression (model, 2 * x - 3 * sin (x))) ==
218- " (2 x) - (3.0 * sin(x))"
218+ " (2 x) - (3 * sin(x))"
219219 @test string (@expression (model, x^ 2 - 3 * sin (x))) ==
220- " ($(x^ 2 ) ) - (3.0 * sin(x))"
220+ " ($(x^ 2 ) ) - (3 * sin(x))"
221221 @test string (@expression (model, sin (x) - 3 * sin (x))) ==
222- " sin(x) - (3.0 * sin(x))"
222+ " sin(x) - (3 * sin(x))"
223223 @test string (@expression (model, sin (x) - 3 * x)) == " sin(x) - (3 x)"
224224 @test string (@expression (model, sin (x) - 3 * x * x)) ==
225225 " sin(x) - (3 $(x^ 2 ) )"
@@ -233,11 +233,11 @@ function test_extension_aff_expr_convert(
233233 model = ModelType ()
234234 @variable (model, x)
235235 _to_string (x) = string (convert (GenericNonlinearExpr{VariableRefType}, x))
236- @test _to_string (AffExpr (0.0 )) == " +(0.0 )"
237- @test _to_string (AffExpr (1.0 )) == " +(1.0 )"
238- @test _to_string (x + 1 ) == " x + 1.0 "
239- @test _to_string (2 x + 1 ) == " (2.0 * x) + 1.0 "
240- @test _to_string (2 x) == " 2.0 * x"
236+ @test _to_string (AffExpr (0.0 )) == " +(0)"
237+ @test _to_string (AffExpr (1.0 )) == " +(1)"
238+ @test _to_string (x + 1 ) == " x + 1"
239+ @test _to_string (2 x + 1 ) == " (2 * x) + 1"
240+ @test _to_string (2 x) == " 2 * x"
241241 return
242242end
243243
@@ -248,17 +248,17 @@ function test_extension_quad_expr_convert(
248248 model = ModelType ()
249249 @variable (model, x)
250250 _to_string (x) = string (convert (GenericNonlinearExpr{VariableRefType}, x))
251- @test _to_string (QuadExpr (AffExpr (0.0 ))) == " +(0.0 )"
252- @test _to_string (QuadExpr (AffExpr (1.0 ))) == " +(1.0 )"
253- @test _to_string (x^ 2 + 1 ) == " (x * x) + 1.0 "
254- @test _to_string (2 x^ 2 + 1 ) == " (2.0 * x * x) + 1.0 "
255- @test _to_string (2 x^ 2 ) == " 2.0 * x * x"
256- @test _to_string (x^ 2 + x + 1 ) == " x + (x * x) + 1.0 "
257- @test _to_string (2 x^ 2 + x + 1 ) == " x + (2.0 * x * x) + 1.0 "
258- @test _to_string (2 x^ 2 + x) == " x + (2.0 * x * x)"
259- @test _to_string (x^ 2 + 2 x + 1 ) == " (2.0 * x) + (x * x) + 1.0 "
260- @test _to_string (2 x^ 2 + 2 x + 1 ) == " (2.0 * x) + (2.0 * x * x) + 1.0 "
261- @test _to_string (2 x^ 2 + 2 x) == " (2.0 * x) + (2.0 * x * x)"
251+ @test _to_string (QuadExpr (AffExpr (0.0 ))) == " +(0)"
252+ @test _to_string (QuadExpr (AffExpr (1.0 ))) == " +(1)"
253+ @test _to_string (x^ 2 + 1 ) == " (x * x) + 1"
254+ @test _to_string (2 x^ 2 + 1 ) == " (2 * x * x) + 1"
255+ @test _to_string (2 x^ 2 ) == " 2 * x * x"
256+ @test _to_string (x^ 2 + x + 1 ) == " x + (x * x) + 1"
257+ @test _to_string (2 x^ 2 + x + 1 ) == " x + (2 * x * x) + 1"
258+ @test _to_string (2 x^ 2 + x) == " x + (2 * x * x)"
259+ @test _to_string (x^ 2 + 2 x + 1 ) == " (2 * x) + (x * x) + 1"
260+ @test _to_string (2 x^ 2 + 2 x + 1 ) == " (2 * x) + (2 * x * x) + 1"
261+ @test _to_string (2 x^ 2 + 2 x) == " (2 * x) + (2 * x * x)"
262262 return
263263end
264264
@@ -337,7 +337,7 @@ function test_user_defined_function_overload()
337337 register (model, :f , 1 , f; autodiff = true )
338338 @test string (@expression (model, f (x))) == " f(x)"
339339 @test string (f (x) + f (x)) == " f(x) + f(x)"
340- @test string (1 / (f (x) + f (x))) == " 1.0 / (f(x) + f(x))"
340+ @test string (1 / (f (x) + f (x))) == " 1 / (f(x) + f(x))"
341341 return
342342end
343343
@@ -447,7 +447,7 @@ function test_extension_expr_mle(
447447 sum ((data[i] - x)^ 2 for i in 1 : n) / (2 * y^ 2 )
448448 )
449449 @test string (obj) ==
450- " (2.0 * log(1.0 / (2 $(y^ 2 ) ))) - ((4 $(x^ 2 ) - 30 x + 85) / (2 $(y^ 2 ) ))"
450+ " (2 * log(1 / (2 $(y^ 2 ) ))) - ((4 $(x^ 2 ) - 30 x + 85) / (2 $(y^ 2 ) ))"
451451 return
452452end
453453
@@ -1006,11 +1006,11 @@ function test_printing_truncation()
10061006 @variable (model, x[1 : 100 ])
10071007 y = @expression (model, sum (sin .(x) .* 2 ))
10081008 @test occursin (
1009- " (sin(x[72]) * 2.0 ) + [[...41 terms omitted...]] + (sin(x[30]) * 2.0 )" ,
1009+ " (sin(x[72]) * 2) + [[...41 terms omitted...]] + (sin(x[30]) * 2)" ,
10101010 function_string (MIME (" text/plain" ), y),
10111011 )
10121012 @test occursin (
1013- " {\\ left({\\ textsf{sin}\\ left({x_{72}}\\ right)} * {2.0 }\\ right) + {[[\\ ldots\\ text{41 terms omitted}\\ ldots]]} + {\\ left({\\ textsf{sin}\\ left({x_{30}}\\ right)} * {2.0 }\\ right)}" ,
1013+ " {\\ left({\\ textsf{sin}\\ left({x_{72}}\\ right)} * {2}\\ right) + {[[\\ ldots\\ text{41 terms omitted}\\ ldots]]} + {\\ left({\\ textsf{sin}\\ left({x_{30}}\\ right)} * {2}\\ right)}" ,
10141014 function_string (MIME (" text/latex" ), y),
10151015 )
10161016 return
0 commit comments