diff --git a/docs/src/conversion.md b/docs/src/conversion.md index c19aced2..a28a3efb 100644 --- a/docs/src/conversion.md +++ b/docs/src/conversion.md @@ -49,7 +49,7 @@ julia> uconvert(Unitful.NoUnits, 1.0u"Ξm/m") 1.0e-6 julia> uconvert(Unitful.NoUnits, 1.0u"m") -ERROR: Unitful.DimensionError() +ERROR: DimensionError: and m are not dimensionally compatible. ``` You can also directly convert to a subtype of `Real` or `Complex`: diff --git a/docs/src/extending.md b/docs/src/extending.md index 3803fbc7..ea492d49 100644 --- a/docs/src/extending.md +++ b/docs/src/extending.md @@ -82,7 +82,7 @@ explicitly forbid any attempt to convert to SI units. One can achieve this by defining new dimensions with the [`@dimension`](@ref) or [`@derived_dimension`](@ref) macros. The trick is to define dimensions that display suggestively like physical dimensions, like 𝐋*, 𝐓* etc., but are distinct as far -as Julia's type system is concerned. Then, you can use [`@ref_unit`](@ref) to +as Julia's type system is concerned. Then, you can use [`@refunit`](@ref) to base units for these new dimensions without reference to SI. The result will be that attempted conversion between the hypothetical unit system and SI will fail with a `DimensionError`, so be sure you provide some hints in how your diff --git a/docs/src/trouble.md b/docs/src/trouble.md index 801776d4..02151fbf 100644 --- a/docs/src/trouble.md +++ b/docs/src/trouble.md @@ -42,8 +42,7 @@ Variables: Body: begin - p::Int64 = 2 - return $(Expr(:invoke, MethodInstance for ^(::Quantity{Float64, Dimensions:{𝐋}, Units:{m}}, ::Int64), :(^), :(x), :(p))) + return $(Expr(:invoke, MethodInstance for ^(::Quantity{Float64, Dimensions:{𝐋}, Units:{m}}, ::Int64), :(^), :(x), 2)) end::Any ``` @@ -64,11 +63,11 @@ Variables: Body: begin $(Expr(:inbounds, false)) - # meta: location /Users/ajkeller/.julia/v0.6/Unitful/src/Unitful.jl ^ 1044 + # meta: location /Users/ajkeller/.julia/v0.6/Unitful/src/Unitful.jl literal_pow 1058 SSAValue(0) = (Core.getfield)(x::Quantity{Float64, Dimensions:{𝐋}, Units:{m}}, :val)::Float64 # meta: pop location $(Expr(:inbounds, :pop)) - return $(Expr(:new, :($(QuoteNode(Quantity{Float64, Dimensions:{𝐋^2}, Units:{m^2}}))), :((Base.mul_float)(SSAValue(0), SSAValue(0))::Float64))) + return $(Expr(:new, Quantity{Float64, Dimensions:{𝐋^2}, Units:{m^2}}, :((Base.mul_float)(SSAValue(0), SSAValue(0))::Float64))) end::Quantity{Float64, Dimensions:{𝐋^2}, Units:{m^2}} ``` diff --git a/src/Unitful.jl b/src/Unitful.jl index b4b1a1c4..2760304b 100644 --- a/src/Unitful.jl +++ b/src/Unitful.jl @@ -167,7 +167,7 @@ julia> unit(1.0u"m") == u"m" true julia> typeof(u"m") -Unitful.Units{(Unitful.Unit{:Meter,Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1),)}}(0,1//1),),Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1),)}} +Unitful.Units{(Unitful.Unit{:Meter,Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1),)}}(0, 1//1),),Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1),)}} ``` """ @inline unit{T,D,U}(x::Quantity{T,D,U}) = U() diff --git a/src/User.jl b/src/User.jl index b96c9e46..cb524fe7 100644 --- a/src/User.jl +++ b/src/User.jl @@ -331,7 +331,7 @@ julia> 1.0u"N*m" 1.0 m N julia> u"m,kg,s" -(m,kg,s) +(m, kg, s) julia> typeof(1.0u"m/s") Quantity{Float64, Dimensions:{𝐋 𝐓^-1}, Units:{m s^-1}}