Git Product home page Git Product logo

Comments (6)

MilesCranmer avatar MilesCranmer commented on June 12, 2024

If you only wish to avoid converting to SI, one option is to use symbolic units: https://github.com/SymbolicML/DynamicQuantities.jl#symbolic-units.

You can also define custom dimensions structs:

struct MyDimensions{R} <: AbstractDimensions{R}
length::R
mass::R
time::R
end

which you could set the default unit system to something else rather than SI.

However, to just register a unit, it's probably safer to just define your own @u_str macro with the different units you would like to make available in the same scope eval is executed.

While you could technically do DynamicQuantities.Units.eval(:(const mph = ...)) for every unit, which would make them available to uparse, this is not at all a safe or robust approach. Globally registering units like this is dangerous so I would recommend the former strategies.

from dynamicquantities.jl.

klaff avatar klaff commented on June 12, 2024

I'm happy to have all the calculations happen in SI and actually prefer to do so. I'm just looking for the cleanest way to convert things on the way in and on the way out. For example, in a previous life I did a lot of DC motor work, and the input units around torque and inertia can be pretty strange. But even for the output, no human (that I know of) thinks in radians/second, so that has to get converted to RPM (which is not of course SI).

P.S. I was happy to see the clever support for fractional powers, as one of my tests for a unit system is if it can handle the motor constant which is in dimensions of torque per sqrt(power).

from dynamicquantities.jl.

MilesCranmer avatar MilesCranmer commented on June 12, 2024

Cool! Okay so once #48 merges, we should be good to go if its just conversion. Then you could do, for example,

0.5u"1/s" |> as_u("1/min")

which would display it in symbolic dimensions of 1/minute. But we're still discussing the API over in that PR.

Cheers,
Miles

P.S. I was happy to see the clever support for fractional powers, as one of my tests for a unit system is if it can handle the motor constant which is in dimensions of torque per sqrt(power).

Awesome, I am glad to hear it has found a use-case!

from dynamicquantities.jl.

klaff avatar klaff commented on June 12, 2024

Thank you for the pointer to that discussion. I think that will probably cover my questions.

from dynamicquantities.jl.

MilesCranmer avatar MilesCranmer commented on June 12, 2024

Closed with #48

from dynamicquantities.jl.

MilesCranmer avatar MilesCranmer commented on June 12, 2024

@klaff FYI we just added mi, ft, and inch.

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.