Skip to content

Commit 8731979

Browse files
Sacha0tkelman
authored andcommitted
Deprecate vectorized div, rem/%, and mod methods for Dates.Periods. (#19802)
1 parent 35d1780 commit 8731979

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

base/dates/periods.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ end
8787
*{P<:Period}(x::P,y::Real) = P(value(x) * Int64(y))
8888
*(y::Real,x::Period) = x * y
8989
for (op,Ty,Tz) in ((:*,Real,:P),
90-
(:/,:P,Float64), (:/,Real,:P),
91-
(:div,:P,Int64), (:div,Integer,:P),
92-
(:%,:P,:P),
93-
(:mod,:P,:P))
90+
(:/,:P,Float64), (:/,Real,:P))
9491
@eval begin
9592
function ($op){P<:Period}(X::StridedArray{P},y::$Ty)
9693
Z = similar(X, $Tz)

base/deprecated.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,12 @@ end
14381438
@deprecate rem(A::Number, B::AbstractArray) rem.(A, B)
14391439
@deprecate rem(A::AbstractArray, B::Number) rem.(A, B)
14401440

1441+
# Deprecate manually vectorized div, mod, and % methods for dates
1442+
@deprecate div{P<:Dates.Period}(X::StridedArray{P}, y::P) div.(X, y)
1443+
@deprecate div{P<:Dates.Period}(X::StridedArray{P}, y::Integer) div.(X, y)
1444+
@deprecate (%){P<:Dates.Period}(X::StridedArray{P}, y::P) X .% y
1445+
@deprecate mod{P<:Dates.Period}(X::StridedArray{P}, y::P) mod.(X, y)
1446+
14411447
# Deprecate manually vectorized mod methods in favor of compact broadcast syntax
14421448
@deprecate mod(B::BitArray, x::Bool) mod.(B, x)
14431449
@deprecate mod(x::Bool, B::BitArray) mod.(x, B)

test/dates/periods.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ t2 = Dates.Year(2)
3535
@test_throws MethodError ([t,t,t,t,t] .* Dates.Year(1)) == ([t,t,t,t,t])
3636
@test ([t,t,t,t,t] * 1) == ([t,t,t,t,t])
3737
@test ([t,t,t,t,t] .% t2) == ([t,t,t,t,t])
38-
@test div([t,t,t,t,t],Dates.Year(1)) == ([1,1,1,1,1])
39-
@test mod([t,t,t,t,t],Dates.Year(2)) == ([t,t,t,t,t])
38+
@test div.([t,t,t,t,t],Dates.Year(1)) == ([1,1,1,1,1])
39+
@test mod.([t,t,t,t,t],Dates.Year(2)) == ([t,t,t,t,t])
4040
@test [t,t,t] / t2 == [0.5,0.5,0.5]
4141
@test abs(-t) == t
4242

0 commit comments

Comments
 (0)