Skip to content

Commit 878b913

Browse files
refactor: make dependent and numeric portions singletons
1 parent a6c39cf commit 878b913

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/systems/index_cache.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ function BufferTemplate(s::Type{<:Symbolics.Struct}, length::Int)
88
BufferTemplate(T, length)
99
end
1010

11-
const DEPENDENT_PORTION = :dependent
12-
const NONNUMERIC_PORTION = :nonnumeric
11+
struct Dependent <: SciMLStructures.AbstractPortion end
12+
struct Nonnumeric <: SciMLStructures.AbstractPortion end
13+
const DEPENDENT_PORTION = Dependent()
14+
const NONNUMERIC_PORTION = Nonnumeric()
1315

1416
struct ParameterIndex{P, I}
1517
portion::P

src/systems/parameter_buffer.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ SciMLStructures.ismutablescimlstructure(::MTKParameters) = true
210210

211211
for (Portion, field) in [(SciMLStructures.Tunable, :tunable)
212212
(SciMLStructures.Discrete, :discrete)
213-
(SciMLStructures.Constants, :constant)]
213+
(SciMLStructures.Constants, :constant)
214+
(Nonnumeric, :nonnumeric)]
214215
@eval function SciMLStructures.canonicalize(::$Portion, p::MTKParameters)
215216
as_vector = buffer_to_arraypartition(p.$field)
216217
repack = let as_vector = as_vector, p = p

0 commit comments

Comments
 (0)