Comments (6)
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 π
from dynamicquantities.jl.
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
from dynamicquantities.jl.
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!
from dynamicquantities.jl.
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.
from dynamicquantities.jl.
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.
from dynamicquantities.jl.
Closed with v0.8!
from dynamicquantities.jl.
Related Issues (20)
- u"β¦" errors in precompilation HOT 6
- Base.isapprox fails for Vector{Quantity} HOT 14
- Meshes.jl test failure HOT 10
- Round tripping Quantities through String HOT 3
- `bionomial` and `factorial` functions not defined? HOT 5
- Molar units not supported HOT 7
- Why `one(1u"kg")` no dimension? HOT 2
- Pretty print element types of `QuantityArray` HOT 2
- How to cite DynamicQuantities.jl? HOT 2
- Immutable constants for symbolic dimensions
- Registering custom unit propagation rules
- Choosing type of quantity value based on type used in construction HOT 1
- Further improvements to startup time HOT 1
- Adding "missing" units HOT 4
- Compatibility with `zero(::Type{T})` HOT 6
- Unitful conversion fails for symbolic units HOT 7
- Sweep: Define `NoDims` for indicating something is not a quantity HOT 2
- `reduce(vcat` returns corrupted result HOT 1
- `map` fails with `QuantityArray` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dynamicquantities.jl.