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 456456# # Guess ======================================================================
457457struct VariableGuess end
458458Symbolics. 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))
460460
461461"""
462462 getguess(x)
@@ -469,8 +469,6 @@ Create variables with a guess like this
469469```
470470"""
471471function getguess (x)
472- p = Symbolics. getparent (x, nothing )
473- p === nothing || (x = p)
474472 Symbolics. getmetadata (x, VariableGuess, nothing )
475473end
476474
Original file line number Diff line number Diff line change @@ -16,6 +16,18 @@ using ModelingToolkit
1616@test hasguess (y) === true
1717@test ModelingToolkit. dump_variable_metadata (y). guess == 0
1818
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+
1931@variables y
2032@test hasguess (y) === false
2133@test ! haskey (ModelingToolkit. dump_variable_metadata (y), :guess )
You can’t perform that action at this time.
0 commit comments