-
-
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
Dates round/floor/ceil arguments switched #47786
Comments
Thanks. We can't remove |
we can deprecate the wrong order, and IMO should do so. |
(Note that deprecations are silent by default, so this is not breaking.) |
Hello, I am new to Open-Source. I have tried Julia and want to get involved in the community. Since, this is a good first issue, can I work on it? Edit: Please, refer to #47843. I have created a Pull request. |
@oscardssmith & @LilithHafner There is one round method that it looks like you create an ambiguity that you can't fix without breaking: function Base.round(precision::ConvertiblePeriod, x::ConvertiblePeriod, r::RoundingMode{:NearestTiesUp})
f, c = floorceil(precision, x)
_x, _f, _c = promote(x, f, c)
return (_x - _f) < (_c - _x) ? f : c
end
Base.round(x::ConvertiblePeriod, precision::ConvertiblePeriod, r::RoundingMode{:NearestTiesUp}) = Base.round(precision, x, r) #@deprecate Please note that this is from my own PR that I was working on before I saw #47843 the bottom line is what typically would be I have a PR ready that covers everything and the tests. Additional definitions of rounding that cause issues # Base.round(x::TimeTypeOrPeriod, p::Period, r::RoundingMode{:Down}) = Base.round(p,x,r) #@deprecate
Base.round(p::Period, x::TimeTypeOrPeriod, r::RoundingMode{:Down}) = Base.floor(p, x)
# Base.round(x::TimeTypeOrPeriod, p::Period, r::RoundingMode{:Up}) = Base.round(p,x,r) #@deprecate
Base.round(p::Period, x::TimeTypeOrPeriod, r::RoundingMode{:Up}) = Base.ceil(p, x)
# Base.round(::TimeTypeOrPeriod, p::Period, ::RoundingMode) = throw(DomainError(p)) #@deprecate
Base.round(p::Period, ::TimeTypeOrPeriod, ::RoundingMode) = throw(DomainError(p))
# Base.round(x::TimeTypeOrPeriod, p::Period) = Base.round(p, x, RoundNearestTiesUp) #@deprecate
Base.round(p::Period, x::TimeTypeOrPeriod) = Base.round(p, x, RoundNearestTiesUp) |
#18574 (comment) says
The positional trunc([T,] x)
trunc(x; digits::Integer= [, base = 10])
trunc(x; sigdigits::Integer= [, base = 10]) so this justification by analogy doesn't apply anymore. |
round(T, x)
is the normal API, but in Dates.jl the arguments are reversed.The text was updated successfully, but these errors were encountered: