Skip to content

Commit 36c1ad6

Browse files
fix: fix bugs with symbolic indexing and MTKParameters
1 parent 0e7c570 commit 36c1ad6

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/systems/index_cache.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,16 @@ end
190190
function check_index_map(idxmap, sym)
191191
if (idx = get(idxmap, sym, nothing)) !== nothing
192192
return idx
193-
elseif hasname(sym) && (idx = get(idxmap, getname(sym), nothing)) !== nothing
193+
elseif !isa(sym, Symbol) && (!istree(sym) || operation(sym) !== getindex) &&
194+
hasname(sym) && (idx = get(idxmap, getname(sym), nothing)) !== nothing
194195
return idx
195196
end
196197
dsym = default_toterm(sym)
197198
isequal(sym, dsym) && return nothing
198199
if (idx = get(idxmap, dsym, nothing)) !== nothing
199200
idx
200-
elseif hasname(dsym) && (idx = get(idxmap, getname(dsym), nothing)) !== nothing
201+
elseif !isa(dsym, Symbol) && (!istree(dsym) || operation(dsym) !== getindex) &&
202+
hasname(dsym) && (idx = get(idxmap, getname(dsym), nothing)) !== nothing
201203
idx
202204
else
203205
nothing

src/systems/parameter_buffer.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,13 @@ function SymbolicIndexingInterface.parameter_values(p::MTKParameters, pind::Para
224224
@unpack portion, idx = pind
225225
i, j, k... = idx
226226
if portion isa SciMLStructures.Tunable
227-
return p.tunable[i][j][k...]
227+
return isempty(k) ? p.tunable[i][j] : p.tunable[i][j][k...]
228228
elseif portion isa SciMLStructures.Discrete
229-
return p.discrete[i][j][k...]
229+
return isempty(k) ? p.discrete[i][j] : p.discrete[i][j][k...]
230230
elseif portion isa SciMLStructures.Constants
231-
return p.constant[i][j][k...]
231+
return isempty(k) ? p.constant[i][j] : p.constant[i][j][k...]
232232
elseif portion === DEPENDENT_PORTION
233-
return p.dependent[i][j][k...]
233+
return isempty(k) ? p.dependent[i][j] : p.dependent[i][j][k...]
234234
elseif portion === NONNUMERIC_PORTION
235235
return isempty(k) ? p.nonnumeric[i][j] : p.nonnumeric[i][j][k...]
236236
else

0 commit comments

Comments
 (0)