-
-
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
support ordinal types in diff(AbstractRange)
#41390
Conversation
expecting What performance implication this will bring is unknown, probably need a comprehensive benchmark in Julia and maybe even other packages where In the dream world we could use If people don't like this, we can move this into Dates with |
Must julia> _diff(r::AbstractRange) = StepRangeLen(step(r), zero(step(r)), length(r)-1);
julia> rr = DateTime(2021,1,1):Hour(1):DateTime(2021,1,2); # from 41336
julia> _diff(rr) == diff(collect(rr))
true And if it must be a Vector, can't it be just |
Well, the issue is right now Personally I think it should, because |
Why the difference is in milliseconds & the step is in years, I don't know, is there a clear preference? Both are time intervals, and I read the bug as being that it returned dates (i.e. times since 0AD) which is the element type but not the type of the difference. And, it seems a little odd to write a specialisation for AbstractRange which doesn't use its structure at all, when what's being computed is so close to the defining property of an AbstractRange. The method as written would work for AbstractVector too, right? If for some reason this must return something |
Because
Because being smart may defy people's intention of adding special |
If you add a method for What I meant when asking "why" was whether there was a reason that |
because
(addition of two well, I more or less agree with you I just don't know if people rely on |
Yes, the difference is of dates is an element of the tangent space, is how I would phrase it. As is the step. It just happens that, along the path to computing the difference, the precise units of the step have been lost, so we get standard ones. Maybe more interesting is to think about monthly steps, where things are't
Oh that's a bug. It's supposed to have special printing for zero step, but should check |
I guess we will still go with what is in the PR now then |
@nanosoldier |
diff(AbstractRange)
diff(AbstractRange)
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @christopher-dG |
We don't have a single call to |
fix #41336