@@ -346,6 +346,9 @@ function SymbolicIndexingInterface.is_variable(sys::AbstractSystem, sym)
346
346
end
347
347
348
348
function SymbolicIndexingInterface. is_variable (sys:: AbstractSystem , sym:: Symbol )
349
+ if has_index_cache (sys) && (ic = get_index_cache (sys)) != = nothing
350
+ return haskey (ic. unknown_idx, hash (sym))
351
+ end
349
352
return any (isequal (sym), getname .(variable_symbols (sys))) ||
350
353
count (' ₊' , string (sym)) == 1 &&
351
354
count (isequal (sym), Symbol .(nameof (sys), :₊ , getname .(variable_symbols (sys)))) ==
@@ -377,6 +380,9 @@ function SymbolicIndexingInterface.variable_index(sys::AbstractSystem, sym)
377
380
end
378
381
379
382
function SymbolicIndexingInterface. variable_index (sys:: AbstractSystem , sym:: Symbol )
383
+ if has_index_cache (sys) && (ic = get_index_cache (sys)) != = nothing
384
+ return get (ic. unknown_idx, h, nothing )
385
+ end
380
386
idx = findfirst (isequal (sym), getname .(variable_symbols (sys)))
381
387
if idx != = nothing
382
388
return idx
@@ -401,19 +407,24 @@ function SymbolicIndexingInterface.is_parameter(sys::AbstractSystem, sym)
401
407
ic = get_index_cache (sys)
402
408
h = getsymbolhash (sym)
403
409
return if haskey (ic. param_idx, h) || haskey (ic. discrete_idx, h) ||
404
- haskey (ic. constant_idx, h) || haskey (ic. dependent_idx, h)
410
+ haskey (ic. constant_idx, h) || haskey (ic. dependent_idx, h) ||
411
+ haskey (ic. nonnumeric_idx, h)
405
412
true
406
413
else
407
414
h = getsymbolhash (default_toterm (sym))
408
415
haskey (ic. param_idx, h) || haskey (ic. discrete_idx, h) ||
409
- haskey (ic. constant_idx, h) || haskey (ic. dependent_idx, h)
416
+ haskey (ic. constant_idx, h) || haskey (ic. dependent_idx, h) ||
417
+ haskey (ic. nonnumeric_idx, h)
410
418
end
411
419
end
412
420
return any (isequal (sym), parameter_symbols (sys)) ||
413
421
hasname (sym) && is_parameter (sys, getname (sym))
414
422
end
415
423
416
424
function SymbolicIndexingInterface. is_parameter (sys:: AbstractSystem , sym:: Symbol )
425
+ if has_index_cache (sys) && (ic = get_index_cache (sys)) != = nothing
426
+ return ParameterIndex (ic, sym) != = nothing
427
+ end
417
428
return any (isequal (sym), getname .(parameter_symbols (sys))) ||
418
429
count (' ₊' , string (sym)) == 1 &&
419
430
count (isequal (sym),
@@ -426,7 +437,6 @@ function SymbolicIndexingInterface.parameter_index(sys::AbstractSystem, sym)
426
437
end
427
438
if has_index_cache (sys) && get_index_cache (sys) != = nothing
428
439
ic = get_index_cache (sys)
429
- h = getsymbolhash (sym)
430
440
return if (idx = ParameterIndex (ic, sym)) != = nothing
431
441
idx
432
442
elseif (idx = ParameterIndex (ic, default_toterm (sym))) != = nothing
@@ -444,6 +454,9 @@ function SymbolicIndexingInterface.parameter_index(sys::AbstractSystem, sym)
444
454
end
445
455
446
456
function SymbolicIndexingInterface. parameter_index (sys:: AbstractSystem , sym:: Symbol )
457
+ if has_index_cache (sys) && (ic = get_index_cache (sys)) != = nothing
458
+ return ParameterIndex (ic, sym)
459
+ end
447
460
idx = findfirst (isequal (sym), getname .(parameter_symbols (sys)))
448
461
if idx != = nothing
449
462
return idx
0 commit comments