File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 286
286
function hasdescription (x)
287
287
getdescription (x) != " "
288
288
end
289
+
290
+ # # binary variables =================================================================
291
+ struct VariableBinary end
292
+ Symbolics. option_to_metadata_type (:: Val{:binary} ) = VariableBinary
293
+
294
+ isbinary (x:: Num ) = isbinary (Symbolics. unwrap (x))
295
+
296
+ """
297
+ isbinary(x)
298
+
299
+ Determine if a variable is binary.
300
+ """
301
+ function isbinary (x)
302
+ p = Symbolics. getparent (x, nothing )
303
+ p === nothing || (x = p)
304
+ return Symbolics. getmetadata (x, VariableBinary, false )
305
+ end
306
+
307
+ # # integer variables =================================================================
308
+ struct VariableInteger end
309
+ Symbolics. option_to_metadata_type (:: Val{:integer} ) = VariableInteger
310
+
311
+ isinteger (x:: Num ) = isinteger (Symbolics. unwrap (x))
312
+
313
+ """
314
+ isinteger(x)
315
+
316
+ Determine if a variable is integer.
317
+ """
318
+ function isinteger (x)
319
+ p = Symbolics. getparent (x, nothing )
320
+ p === nothing || (x = p)
321
+ return Symbolics. getmetadata (x, VariableInteger, false )
322
+ end
Original file line number Diff line number Diff line change @@ -82,3 +82,19 @@ sp = Set(p)
82
82
@named sys = ODESystem ([u ~ p], t)
83
83
84
84
@test_nowarn show (stdout , " text/plain" , sys)
85
+
86
+ @testset " binary" begin
87
+ @parameters t
88
+ @variables u (t) [binary = true ]
89
+ @parameters p [binary = true ]
90
+ @test isbinary (u)
91
+ @test isbinary (p)
92
+ end
93
+
94
+ @testset " integer" begin
95
+ @parameters t
96
+ @variables u (t) [integer = true ]
97
+ @parameters p [integer = true ]
98
+ @test isinteger (u)
99
+ @test isinteger (p)
100
+ end
You can’t perform that action at this time.
0 commit comments