-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds retime #529
base: master
Are you sure you want to change the base?
Adds retime #529
Conversation
It works off of #528 |
@iblislin What do you think about the interface? I have chosen singleton types instead of Symbols so that a dispatch system can be implemented. |
well, I personally prefer the Symbol, and build with literal type dispatching. e.g. julia> f(::Val{:abc}) = 42
f (generic function with 1 method)
julia> f(x::Symbol) = f(Val(x))
f (generic function with 2 methods)
julia> f(:abc)
42 but I'm not sure about the performance penalty. Maybe you could give that a try. |
@iblislin I added a documentation page as well. |
Could you sync (rebase or just merge) this branch with master? |
minor return iterator and adds test starts to add retime changes _split changes LTS overload Base.split changes interface of _split to return timestamps
adds missing deps another missing dep support symbols as well handle missing data adds docs on retime minor
095736e
to
48d72ab
Compare
Done |
@iblislin any thoughts? |
Any idea about the Documenter build failures? Tons of |
Not really. |
Could you check that is |
src/retime.jl
Outdated
_toExtrapolationMethod(x::ExtrapolationMethod) = x | ||
|
||
function retime(ta, new_dt::Dates.Period; kwargs...) | ||
new_timestamps = timestamp(ta)[1]:new_dt:timestamp(ta)[end] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the expected result in Matlab for this case?
julia> ta = TimeArray([DateTime(2025, 1, 1, 8, 0), DateTime(2025, 1, 2, 2, 0), DateTime(2025, 1, 3, 9, 0)], [1,1, 42])
3×1 TimeArray{Int64, 1, DateTime, Vector{Int64}} 2025-01-01T08:00:00 to 2025-01-03T09:00:00
┌─────────────────────┬────┐
│ │ A │
├─────────────────────┼────┤
│ 2025-01-01T08:00:00 │ 1 │
│ 2025-01-02T02:00:00 │ 1 │
│ 2025-01-03T09:00:00 │ 42 │
└─────────────────────┴────┘
julia> retime(ta, Day(1); downsample=:sum)
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>> ta = timetable([datetime(2025, 1, 1, 8, 0, 0); datetime(2025, 1, 2, 2, 0, 0); datetime(2025, 1, 3, 9, 0, 0)], ...
[1; 1; 42], ...
'VariableNames', {'Values'})
ta =
Time Values
____________________ ______
01-Jan-2025 08:00:00 1
02-Jan-2025 02:00:00 1
03-Jan-2025 09:00:00 42
>> ta_daily = retime(ta, 'daily', 'sum')
ta_daily =
Time Values
____________________ ______
01-Jan-2025 00:00:00 1
02-Jan-2025 00:00:00 1
03-Jan-2025 00:00:00 42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
julia> ta = TimeArray([DateTime(2025, 1, 1, 8, 0), DateTime(2025, 1, 2, 2, 0), DateTime(2025, 1, 3, 9, 0)], [1,1, 42])
3×1 TimeArray{Int64, 1, DateTime, Vector{Int64}} 2025-01-01T08:00:00 to 2025-01-03T09:00:00
┌─────────────────────┬────┐
│ │ A │
├─────────────────────┼────┤
│ 2025-01-01T08:00:00 │ 1 │
│ 2025-01-02T02:00:00 │ 1 │
│ 2025-01-03T09:00:00 │ 42 │
└─────────────────────┴────┘
julia> retime(ta, Day(1); downsample=:sum)
3×1 TimeArray{Int64, 2, DateTime, Matrix{Int64}} 2025-01-01T00:00:00 to 2025-01-03T00:00:00
┌─────────────────────┬───┐
│ │ A │
├─────────────────────┼───┤
│ 2025-01-01T00:00:00 │ 1 │
│ 2025-01-02T00:00:00 │ 1 │
│ 2025-01-03T00:00:00 │ 1 │
└─────────────────────┴───┘
Our result is different, since upsampling and downsampling are used depending on the number of samples found in the interval. Here, only one sample is found, but not at the asked position; hence interpolation is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no sample is found, it is interpolation.
If there are multiple samples, it is aggregation.
The question is what to do when exactly one sample is found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, for the case of exactly one sample is found, could it be identity
?
since I'm thinking about this:
- What happened if we have a custom aggregation method like
(x, y) -> x + 2y
in Matlab?
Closes #439