-
Notifications
You must be signed in to change notification settings - Fork 2
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
Sn/ignore bad dates #17
base: main
Are you sure you want to change the base?
Conversation
src/PeriodicSelector.jl
Outdated
@@ -33,7 +33,7 @@ struct PeriodicSelector <: DateSelector | |||
end | |||
|
|||
|
|||
function Iterators.partition(dates::StepRange{Date, Day}, s::PeriodicSelector) | |||
function Iterators.partition(dates::StepRange{Date, Day}, s::PeriodicSelector; bad_dates=[]) |
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.
I suggest renaming this to exclude
and making default arg typed.
Here and everywhere else
function Iterators.partition(dates::StepRange{Date, Day}, s::PeriodicSelector; bad_dates=[]) | |
function Iterators.partition(dates::StepRange{Date, Day}, s::PeriodicSelector; exclude=Date[]) |
test/RandomSelector.jl
Outdated
@test !any(is_bad.(validation)) | ||
@test !any(is_bad.(holdout)) |
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.
Not really a performance issue here, but in general best practice is:
@test !any(is_bad.(validation)) | |
@test !any(is_bad.(holdout)) | |
@test !any(is_bad, validation) | |
@test !any(is_bad, holdout) |
as it avoids allocations
test/PeriodicSelector.jl
Outdated
@@ -118,4 +118,16 @@ | |||
@test initial_sets.validation ∩ later_sets.holdout == Set() | |||
end | |||
end | |||
|
|||
@testset "1 week period, 1 day stride, remove the first two holdout dates" begin |
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.
@testset "1 week period, 1 day stride, remove the first two holdout dates" begin | |
@testset "1 week period, 1 day stride, remove the first holdout dates" begin |
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.
Why is this approach better than adding another selector (as suggested in #14)?
this is equivelent to map(d->filter(!in(bad_dates), d), partition(dates, selector)) I wonder if we might want to instead define a filter_partitions(by, parts) = map(d->filter(by, d), parts) which could be used for this and other things as well |
I considered doing another selector, but modifying partition felt more natural, since excluding dates is something one might want regardless of date selection technique.
Yes this feels like possibly a good in-between? Again the issue is that client modules that use |
Oh, I assumed that selectors are composable, but that does not seem to be the case.
Hmm, I'm not sure I understand this entirely. Would it not be possible to just do: validation, holdout = filter_partitions(!in(excluded_dates), partition(...)) in client code? |
They are, i'd actually misread the issue. I think that solution is much better after some thought, so I'll overhaul the PR in a bit. No need to open another issue! |
#14
The purpose of this PR is to add a bad_date optional argument to the
partition
function which allows the user to specify date that should be dropped. This should be useful in a number of downstream applications.