-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Remove problematic Dates conversions #19920
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -478,10 +478,10 @@ let n=100000 | |
return b | ||
end | ||
|
||
@test length(Dates.Year(1):Dates.Year(10)) == 10 | ||
@test length(Dates.Year(1):Dates.Year(1):Dates.Year(10)) == 10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to specify the step here? Can't we just define the following to get the old behaviour? Base.colon{T<:Period}(start::T, stop::T) = StepRange(start, T(1), stop) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's dangerous to define ranges with unitful quantities if you don't explicitly specify the step, because with unitful quantities we tend to think that there's an underlying physical reality independent of the units you choose to express the quantities in. Why should In my mind the only reasonable approach is to force the user to specify the step or the desired length of the range. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with requiring the user to specify the step, but this change should be documented. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In principle I agree that you should define step for unitful ranges. However since ranges involving periods currently require that the endpoints and the step are of the same unit I think this change is mostly just inconvenient. Overall though I'm happy with the change if it leads to less confusion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see the sense in supporting it when you're typing the endpoints explicitly: I think it's pretty obvious what the user wants with function foo(a::Period, b::Period)
ap, bp = promote(a, b)
ap:bp
end where now knowing what you'll get relies on a fair amount of mental gymnastics. Either way, I agree completely with the perspective that we need a transitional strategy. I suspect a deprecation would suffice? |
||
@test length(Dates.Year(10):Dates.Year(-1):Dates.Year(1)) == 10 | ||
@test length(Dates.Year(10):Dates.Year(-2):Dates.Year(1)) == 5 | ||
@test_throws OverflowError length(typemin(Dates.Year):typemax(Dates.Year)) | ||
@test_throws OverflowError length(typemin(Dates.Year):Dates.Year(1):typemax(Dates.Year)) | ||
@test_throws MethodError Dates.Date(0):Dates.DateTime(2000) | ||
@test_throws MethodError Dates.Date(0):Dates.Year(10) | ||
@test length(range(Dates.Date(2000),366)) == 366 | ||
|
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.
this only warns, not throws - strangely it doesn't fail unless you run the tests with
JULIA_CPU_CORES=1
thoughThere 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'll probably comment this out in #20226, but I wonder whether there's a test-system bug here.