@@ -336,14 +336,15 @@ function Base.copy(p::MTKParameters)
336
336
end
337
337
338
338
function SymbolicIndexingInterface. parameter_values (p:: MTKParameters , pind:: ParameterIndex )
339
+ _ducktyped_parameter_values (p, pind)
340
+ end
341
+ function _ducktyped_parameter_values (p, pind:: ParameterIndex )
339
342
@unpack portion, idx = pind
340
343
if portion isa SciMLStructures. Tunable
341
344
return idx isa Int ? p. tunable[idx] : view (p. tunable, idx)
342
345
end
343
346
i, j, k... = idx
344
- if portion isa SciMLStructures. Tunable
345
- return isempty (k) ? p. tunable[i][j] : p. tunable[i][j][k... ]
346
- elseif portion isa SciMLStructures. Discrete
347
+ if portion isa SciMLStructures. Discrete
347
348
return isempty (k) ? p. discrete[i][j] : p. discrete[i][j][k... ]
348
349
elseif portion isa SciMLStructures. Constants
349
350
return isempty (k) ? p. constant[i][j] : p. constant[i][j][k... ]
@@ -444,11 +445,13 @@ function validate_parameter_type(ic::IndexCache, stype, sz, sym, index, val)
444
445
# Nonnumeric parameters have to match the type
445
446
if portion === NONNUMERIC_PORTION
446
447
val isa stype && return nothing
447
- throw (ParameterTypeException (:validate_parameter_type , sym, stype, val))
448
+ throw (ParameterTypeException (
449
+ :validate_parameter_type , sym === nothing ? index : sym, stype, val))
448
450
end
449
451
# Array parameters need array values...
450
452
if stype <: AbstractArray && ! isa (val, AbstractArray)
451
- throw (ParameterTypeException (:validate_parameter_type , sym, stype, val))
453
+ throw (ParameterTypeException (
454
+ :validate_parameter_type , sym === nothing ? index : sym, stype, val))
452
455
end
453
456
# ... and must match sizes
454
457
if stype <: AbstractArray && sz != Symbolics. Unknown () && size (val) != sz
@@ -465,15 +468,16 @@ function validate_parameter_type(ic::IndexCache, stype, sz, sym, index, val)
465
468
# This is for duals and other complicated number types
466
469
etype = SciMLBase. parameterless_type (etype)
467
470
eltype (val) <: etype || throw (ParameterTypeException (
468
- :validate_parameter_type , sym, AbstractArray{etype}, val))
471
+ :validate_parameter_type , sym === nothing ? index : sym , AbstractArray{etype}, val))
469
472
else
470
473
# Real check
471
474
if stype <: Real
472
475
stype = Real
473
476
end
474
477
stype = SciMLBase. parameterless_type (stype)
475
478
val isa stype ||
476
- throw (ParameterTypeException (:validate_parameter_type , sym, stype, val))
479
+ throw (ParameterTypeException (
480
+ :validate_parameter_type , sym === nothing ? index : sym, stype, val))
477
481
end
478
482
end
479
483
0 commit comments