-
-
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
Enable deprecations for non-broadcasted Dates arithmetic. #49832
base: master
Are you sure you want to change the base?
Conversation
@test t2 - t1 == [Dates.Day(1) Dates.Day(31) Dates.Day(365); Dates.Day(365) Dates.Day(28) Dates.Day(1)] | ||
@test t4 - t3 == [Dates.Millisecond(1000), Dates.Millisecond(60000), Dates.Millisecond(3600000)] |
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> typeof(t1)
Matrix{Date} (alias for Array{Date, 2})
julia> typeof(t2)
Matrix{Date} (alias for Array{Date, 2})
julia> methods(-, (Matrix{Date},Matrix{Date}))
# 1 method for generic function "-" from Base:
[1] -(A::AbstractArray, B::AbstractArray)
@ arraymath.jl:6
Perhaps this usage is not deprecated.
@test_deprecated "use `x .- y` instead" t1 - Dates.Day(1) | ||
@test_deprecated "use `x .- y` instead" t3 - Dates.Hour(1) | ||
@test_deprecated "use `x .- y` instead" t1 - (Dates.Month(1) + Dates.Day(1)) | ||
@test_deprecated "use `x .- y` instead" t3 - (Dates.Hour(1) + Dates.Minute(1)) | ||
@test t2 - t1 == [Dates.Day(1) Dates.Day(31) Dates.Day(365); Dates.Day(365) Dates.Day(28) Dates.Day(1)] | ||
@test t4 - t3 == [Dates.Millisecond(1000), Dates.Millisecond(60000), Dates.Millisecond(3600000)] | ||
@test (Dates.Date(2009, 1, 1):Dates.Week(1):Dates.Date(2009, 1, 21)) - (Dates.Date(2009, 1, 1):Dates.Day(1):Dates.Date(2009, 1, 3)) == [Dates.Day(0), Dates.Day(6), Dates.Day(12)] |
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> typeof((Dates.DateTime(2009, 1, 1, 1, 1, 1):Dates.Second(1):Dates.DateTime(2009, 1, 1, 1, 1, 3)))
StepRange{DateTime, Second}
julia> methods(-, (StepRange{DateTime, Second},StepRange{DateTime, Second}))
# 1 method for generic function "-" from Base:
[1] -(x::OrdinalRange{T}, y::OrdinalRange{T}) where T<:TimeType
@ Dates /mnt/v/julia/usr/share/julia/stdlib/v1.10/Dates/src/arithmetic.jl:95
julia/stdlib/Dates/src/arithmetic.jl
Lines 94 to 96 in 78fbf1b
# AbstractArray{TimeType}, AbstractArray{TimeType} | |
(-)(x::OrdinalRange{T}, y::OrdinalRange{T}) where {T<:TimeType} = Vector(x) - Vector(y) | |
(-)(x::AbstractRange{T}, y::AbstractRange{T}) where {T<:TimeType} = Vector(x) - Vector(y) |
Perhaps this usage is not deprecated.
@@ -92,6 +92,7 @@ end | |||
|
|||
(*)(A::Period, B::AbstractArray) = Broadcast.broadcast_preserving_zero_d(*, A, B) | |||
(*)(A::AbstractArray, B::Period) = Broadcast.broadcast_preserving_zero_d(*, A, B) | |||
(/)(A::AbstractArray, B::Period) = Broadcast.broadcast_preserving_zero_d(/, A, B) |
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.
Shouldn't actually be deprecated, see #34786 (which tests this).
Originally posted by
@fredrikekre
in #46093 (comment)
b36b483
to
390dfe4
Compare
fix #37814, replace #46093