25 implement duration as a subtype of number #26
Merged
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.
@andreapasquale94 let's discuss whether these could be usefull changes:
Duration(sec::Int, frac::T)
has been removed since it equals the default type constructor.Base.convert
andBase.promote_rule
have been implemented forDuration
. CurrentlyBase.convert
can be used in two ways (although the first option could be removed):The
ftype
function has been added to retrieve the type in which the fractional part of theDuration
is represented.Epoch
constructors have also been updated to reflect the above changes and avoid code repetitions.Addition and subtraction implementations of
Epoch
have been simplified. Additionally, they now properly propagate types. In the previous implementation, summing an epoch of typeEpoch{TDB, Float64}
with a duration or number of typeBigFloat
would improperly return an epoch inFloat64
representation, leading to a loss in accuracy. Now, the result is expressed using the highest accuracy type (i.e., the one resulting from thepromote_rule
operation).The step length operation to generate a range of epochs with a daily step range has been re-implemented. Thus
ep1:ep2
now properly works again.Note that even though
Duration
is a subtype ofNumber
, all operations that have not been defined, i.e., multiplication and division, will return an error upon execution.