-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support dims Arrays using the HoD Tranform
- Loading branch information
Showing
2 changed files
with
131 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
""" | ||
CustomTransform <: Transform | ||
HoD <: Transform | ||
Apply the function passed in to CustomTransform as the transform. | ||
Get the hour of day corresponding to the data. | ||
""" | ||
struct HoD <: Transform end | ||
|
||
function _apply!(x, ::HoD; kwargs...) | ||
x[:] = hour.(x) | ||
return x | ||
end | ||
|
||
# struct HoW() <: Transform end | ||
_apply(x, ::HoD) = hour.(x) | ||
|
||
# function _apply!(x, ::HoD; kwargs...) | ||
function apply(A::AbstractArray, t::HoD; dims=:, kwargs...) | ||
dims == Colon() && return _apply(A, t; kwargs...) | ||
|
||
# function hour_of_week(x) | ||
# # TODO: this doesn't handle DST | ||
# return dayofweek(x) * 24 + hour(x) | ||
# end | ||
# x[:] = hour_of_week.(x) | ||
# return x | ||
# end | ||
return [_apply(x, t; kwargs...) for x in eachslice(A, dims=dims)] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters