Git Product home page Git Product logo

Comments (6)

gaurav-arya avatar gaurav-arya commented on June 11, 2024 1

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.

MilesCranmer avatar MilesCranmer commented on June 11, 2024

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.

MilesCranmer avatar MilesCranmer commented on June 11, 2024

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.

jkrumbiegel avatar jkrumbiegel commented on June 11, 2024

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.

MilesCranmer avatar MilesCranmer commented on June 11, 2024

Cool!

The remaining problems were all due to zero not being defined on Type{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.

MilesCranmer avatar MilesCranmer commented on June 11, 2024

Closed with v0.8!

from dynamicquantities.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.