Skip to content

Commit 943c748

Browse files
committed
Ensure consistency of unit types
1 parent 55fbf51 commit 943c748

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/units.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ const mol = Quantity(DEFAULT_UNIT_TYPE(1.0), amount=1)
5757
"Frequency in Hertz. Available variants: `kHz`, `MHz`, `GHz`."
5858
const Hz = inv(s)
5959
"Force in Newtons."
60-
const N = kg * m / (s * s)
60+
const N = kg * m / s^2
6161
"Pressure in Pascals. Available variant: `kPa`."
62-
const Pa = N / (m * m)
62+
const Pa = N / m^2
6363
"Energy in Joules. Available variant: `kJ`."
6464
const J = N * m
6565
"Power in Watts. Available variants: `kW`, `MW`, `GW`."
@@ -104,7 +104,7 @@ const yr = DEFAULT_UNIT_TYPE(365.25) * day
104104

105105
## Volume
106106
"Volume in liters. Available variants: `mL`, `dL`."
107-
const L = dm * dm * dm
107+
const L = dm^3
108108

109109
@add_prefixes L (m, d)
110110

@@ -127,12 +127,12 @@ Parse a string containing an expression of units and return the
127127
corresponding `Quantity` object with `Float64` value. For example,
128128
`uparse("m/s")` would be parsed to `Quantity(1.0, length=1, time=-1)`.
129129
"""
130-
function uparse(s::AbstractString)::Quantity{LazyFloat64,DEFAULT_DIM_TYPE}
130+
function uparse(s::AbstractString)::Quantity{DEFAULT_UNIT_TYPE,DEFAULT_DIM_TYPE}
131131
return as_quantity(eval(Meta.parse(s)))
132132
end
133133

134134
as_quantity(q::Quantity) = q
135-
as_quantity(x::Number) = Quantity(convert(LazyFloat64, x), DEFAULT_DIM_TYPE)
135+
as_quantity(x::Number) = Quantity(convert(DEFAULT_UNIT_TYPE, x), DEFAULT_DIM_TYPE)
136136
as_quantity(x) = error("Unexpected type evaluated: $(typeof(x))")
137137

138138
"""

0 commit comments

Comments
 (0)