Skip to content

Commit ff3d518

Browse files
committed
Replace Expronicon with Moshi
1 parent c01ffa5 commit ff3d518

File tree

3 files changed

+17
-33
lines changed

3 files changed

+17
-33
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
1212
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
1313
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1414
EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
15-
Expronicon = "6b7a57c9-7cc1-4fdf-b7f5-e857abae3636"
1615
FunctionWrappersWrappers = "77dc65aa-8811-40c2-897b-53d922fa7daf"
1716
IteratorInterfaceExtensions = "82899510-4779-5014-852e-03e436cf321d"
1817
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1918
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
2019
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
20+
Moshi = "2e0e35c7-a2e4-4343-998d-7ef72827ed2d"
2121
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
2222
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
2323
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
@@ -62,14 +62,14 @@ DataFrames = "1.6"
6262
Distributed = "1.10"
6363
DocStringExtensions = "0.9"
6464
EnumX = "1"
65-
Expronicon = "0.8"
6665
ForwardDiff = "0.10.36"
6766
FunctionWrappersWrappers = "0.1.3"
6867
IteratorInterfaceExtensions = "^1"
6968
LinearAlgebra = "1.10"
7069
Logging = "1.10"
7170
Makie = "0.20, 0.21, 0.22"
7271
Markdown = "1.10"
72+
Moshi = "0.3"
7373
NonlinearSolve = "3, 4"
7474
PartialFunctions = "1.1"
7575
PrecompileTools = "1.2"

src/SciMLBase.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import RuntimeGeneratedFunctions
2323
import EnumX
2424
import ADTypes: ADTypes, AbstractADType
2525
import Accessors: @set, @reset, @delete, @insert
26-
using Expronicon.ADT: @match
26+
using Moshi.Data: @data
27+
using Moshi.Match: @match
2728

2829
using Reexport
2930
using SciMLOperators

src/clock.jl

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
module Clocks
2-
3-
export TimeDomain
4-
5-
using Expronicon.ADT: variant_type, @adt, @match
6-
7-
@adt TimeDomain begin
1+
@data Clocks begin
82
Continuous
93
struct PeriodicClock
104
dt::Union{Nothing, Float64, Rational{Int}}
@@ -13,21 +7,10 @@ using Expronicon.ADT: variant_type, @adt, @match
137
SolverStepClock
148
end
159

16-
Base.Broadcast.broadcastable(d::TimeDomain) = Ref(d)
17-
18-
const DiscriminatorType = typeof(variant_type(Continuous))
19-
20-
function Base.write(io::IO, x::DiscriminatorType)
21-
write(io, Base.reinterpret(UInt32, x))
22-
end
23-
24-
function Base.read(io::IO, ::Type{DiscriminatorType})
25-
Base.reinterpret(DiscriminatorType, read(io, UInt32))
26-
end
27-
28-
end
10+
const TimeDomain = Clocks.Type
11+
using .Clocks: Continuous, PeriodicClock, SolverStepClock
2912

30-
using .Clocks
13+
Base.Broadcast.broadcastable(d::TimeDomain) = Ref(d)
3114

3215
"""
3316
Clock(dt)
@@ -55,27 +38,27 @@ filters.
5538
""" SolverStepClock
5639

5740
isclock(c) = @match c begin
58-
PeriodicClock(_...) => true
41+
PeriodicClock() => true
5942
_ => false
6043
end
6144

6245
issolverstepclock(c) = @match c begin
63-
&SolverStepClock => true
46+
SolverStepClock() => true
6447
_ => false
6548
end
6649

6750
iscontinuous(c) = @match c begin
68-
&Continuous => true
51+
Continuous() => true
6952
_ => false
7053
end
7154

7255
is_discrete_time_domain(c) = !iscontinuous(c)
7356

7457
function first_clock_tick_time(c, t0)
7558
@match c begin
76-
PeriodicClock(dt, _...) => ceil(t0 / dt) * dt
77-
&SolverStepClock => t0
78-
&Continuous => error("Continuous is not a discrete clock")
59+
PeriodicClock(dt) => ceil(t0 / dt) * dt
60+
SolverStepClock() => t0
61+
Continuous() => error("Continuous is not a discrete clock")
7962
end
8063
end
8164

@@ -90,13 +73,13 @@ function canonicalize_indexed_clock(ic::IndexedClock, sol::AbstractTimeseriesSol
9073
c = ic.clock
9174

9275
return @match c begin
93-
PeriodicClock(dt, _...) => ceil(sol.prob.tspan[1] / dt) * dt .+ (ic.idx .- 1) .* dt
94-
&SolverStepClock => begin
76+
PeriodicClock(dt) => ceil(sol.prob.tspan[1] / dt) * dt .+ (ic.idx .- 1) .* dt
77+
SolverStepClock() => begin
9578
ssc_idx = findfirst(eachindex(sol.discretes)) do i
9679
!isa(sol.discretes[i].t, AbstractRange)
9780
end
9881
sol.discretes[ssc_idx].t[ic.idx]
9982
end
100-
&Continuous => sol.t[ic.idx]
83+
Continuous() => sol.t[ic.idx]
10184
end
10285
end

0 commit comments

Comments
 (0)