-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create LazyFloat64 type for units #30
Conversation
src/units.jl
Outdated
@@ -126,12 +127,12 @@ Parse a string containing an expression of units and return the | |||
corresponding `Quantity` object with `Float64` value. For example, | |||
`uparse("m/s")` would be parsed to `Quantity(1.0, length=1, time=-1)`. | |||
""" | |||
function uparse(s::AbstractString) | |||
return as_quantity(eval(Meta.parse(s)))::Quantity{DEFAULT_VALUE_TYPE,DEFAULT_DIM_TYPE} | |||
function uparse(s::AbstractString)::Quantity{LazyFloat64,DEFAULT_DIM_TYPE} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures that any unit is converted to a LazyFloat64 at the end. So even u"1.0"
would become a LazyFloat64.
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
[Diff since v0.5.0](v0.5.0...v0.6.0) **Closed issues:** - Physical constants (#26) **Merged pull requests:** - Create (1) physical constants, and (2) symbolic dimensions object (#32) (@MilesCranmer)
Actually I think it's better if we only demote to abstract floats, but try to promote for everything else. Then we don't have to worry about integers. |
Moved to #66 |
This PR creates the
LazyFloat64
type for storing units. It makes units try to demote their numeric type, rather than promote everything toFloat64
:@mcabbott could you review this?