File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 456
456
# # Guess ======================================================================
457
457
struct VariableGuess end
458
458
Symbolics. option_to_metadata_type (:: Val{:guess} ) = VariableGuess
459
- getguess (x:: Num ) = getguess (Symbolics. unwrap (x))
459
+ getguess (x:: Union{ Num, Symbolics.Arr} ) = getguess (Symbolics. unwrap (x))
460
460
461
461
"""
462
462
getguess(x)
@@ -469,8 +469,6 @@ Create variables with a guess like this
469
469
```
470
470
"""
471
471
function getguess (x)
472
- p = Symbolics. getparent (x, nothing )
473
- p === nothing || (x = p)
474
472
Symbolics. getmetadata (x, VariableGuess, nothing )
475
473
end
476
474
Original file line number Diff line number Diff line change @@ -16,6 +16,18 @@ using ModelingToolkit
16
16
@test hasguess (y) === true
17
17
@test ModelingToolkit. dump_variable_metadata (y). guess == 0
18
18
19
+ # Issue#2653
20
+ @variables y[1 : 3 ] [guess = ones (3 )]
21
+ @test getguess (y) == ones (3 )
22
+ @test hasguess (y) === true
23
+ @test ModelingToolkit. dump_variable_metadata (y). guess == ones (3 )
24
+
25
+ for i in 1 : 3
26
+ @test getguess (y[i]) == 1.0
27
+ @test hasguess (y[i]) === true
28
+ @test ModelingToolkit. dump_variable_metadata (y[i]). guess == 1.0
29
+ end
30
+
19
31
@variables y
20
32
@test hasguess (y) === false
21
33
@test ! haskey (ModelingToolkit. dump_variable_metadata (y), :guess )
You can’t perform that action at this time.
0 commit comments