Closed jkrumbiegel closed 11 months ago
Hi @jkrumbiegel,
Thanks for this note! I would consider this a bug because supporting missing-handling functions should be important, but hasn't really been considered in depth. So the current behavior should be changed.
Do you think you could create a suite of unittests for the behavior you are looking for? (Maybe in a PR.) Then I can add the missing functions to make them pass.
Cheers, Miles
Actually I think once #49 merges, this will already be working, because then AbstractQuantity <: Number
and therefore the built-in functions for missing
would already propagate!
Oh, I see, then this behavior stems from Number
. Great, that was the other thing that caused some headaches with integration. So I'll wait for #49 to merge before proceeding. The remaining problems were all due to zero
not being defined on Type{Quantity}
but that's expected.
Cool!
The remaining problems were all due to
zero
not being defined onType{Quantity}
but that's expected.
Yeah, unfortunately this is a fundamental difference between type-based units and value-based units. The solution is to switch to using zero(::Quantity)
so it can see both the values and the types – this will work for both Unitful and DynamicQuantities.
Yeah, unfortunately this is a fundamental difference between type-based units and value-based units. The solution is to switch to using zero(::Quantity) so it can see both the values and the types – this will work for both Unitful and DynamicQuantities.
A nice analogy could be arrays/matrices also have the same behavior, requiring zero
of the value since the size is not part of the type. This also means we can at least expect any functions that have been written to support array inputs (e.g. sum
) to already get this right 🙂
Closed with v0.8!
When trying to integrate DynamicQuantities support into an existing code base, I noticed that one difficulty came from its different behavior regarding
missing
.The lower version is Unitful. Because
missing
s are wrapped withinQuantity
in DynamicQuantities, a whole host of missing-handling functions doesn't work and quantities have to be unwrapped manually. As the simplest example,ismissing(missing * DynamicQuantities.us"hr") === false
. What was the rationale for this behavior, could it still be changed?