Skip to content

Commit

Permalink
fixup! refactor: use clock from SciMLBase, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Jul 24, 2024
1 parent 9a0ba96 commit ef1e4af
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/discretedomain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,18 @@ julia> x(k) # no shift
x(t)
julia> x(k+1) # shift
Shift(t, 1)(x(t))
Shift(1)(x(t))
```
"""
struct ShiftIndex
clock::Union{InferredTimeDomain, TimeDomain, IntegerSequence}
steps::Int
function ShiftIndex(
clock::Union{TimeDomain, InferredTimeDomain} = Inferred, steps::Int = 0)
clock::Union{TimeDomain, InferredTimeDomain, IntegerSequence} = Inferred, steps::Int = 0)
new(clock, steps)
end
ShiftIndex(dt::Real, steps::Int = 0) = new(Clock(dt), steps)
ShiftIndex(t::Num, steps::Int = 0) = new(IntegerSequence(), steps)
ShiftIndex(::Num, steps::Int) = new(IntegerSequence(), steps)
end

function (xn::Num)(k::ShiftIndex)
Expand All @@ -207,11 +207,6 @@ function (xn::Num)(k::ShiftIndex)
args = Symbolics.arguments(vars[]) # args should be one element vector with the t in x(t)
length(args) == 1 ||
error("Cannot shift an expression with multiple independent variables $x.")
t = args[]
if hasfield(typeof(clock), :t)
isequal(t, clock.t) ||
error("Independent variable of $xn is not the same as that of the ShiftIndex $(k.t)")
end

# d, _ = propagate_time_domain(xn)
# if d != clock # this is only required if the variable has another clock
Expand Down

0 comments on commit ef1e4af

Please sign in to comment.