Return the same type from timeencode if the units are not changing#68
Open
felixcremer wants to merge 2 commits into
Open
Return the same type from timeencode if the units are not changing#68felixcremer wants to merge 2 commits into
felixcremer wants to merge 2 commits into
Conversation
This is to circumvent changing the element type of the DateTime object which can lead to downstream problems.
Member
Actually, the problem is that types depend on the values (units, calendar). For a large arrays, this can be quite slow. There is a lot of this code, that can be done differently since the time origin and the news are now flexible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When I am doing a timedecode and then a timeencode with the same underlying units I would have expected that we get the same type back. This is fixed here by comparing the old and the new units. And if so not dealing with the plength but returning the difference immediately.
While implementing this, I was wondering why the main work of the timeencode function is in a dispatch for an AbstractArray and then we wrap the single instance in an array. We could also do the main work in the method for a single element and make the one for the abstractArray be a broadcasted version of this method.
This would make it easier to specify the timeencode behaviour of specific types.
For example we could get rid of the if ismissing case by dispatching on missing and having a
timeencode(::Missing) = missingmethod.