You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Base.zero(::Dimensions) =error("There is no such thing as an additive identity for a `Dimensions` object, as + is only defined for `Quantity`.")
65
+
Base.zero(::Type{<:Quantity}) =error("Cannot create an additive identity for a `Quantity` type, as the dimensions are unknown. Please use `zero(::Quantity)` instead.")
66
+
Base.zero(::Type{<:Dimensions}) =error("There is no such thing as an additive identity for a `Dimensions` type, as + is only defined for `Quantity`.")
Base.oneunit(::Dimensions) =error("There is no such thing as a dimensionful 1 for a `Dimensions` object, as + is only defined for `Quantity`.")
71
+
Base.oneunit(::Type{<:Quantity}) =error("Cannot create a dimensionful 1 for a `Quantity` type without knowing the dimensions. Please use `oneunit(::Quantity)` instead.")
72
+
Base.oneunit(::Type{<:Dimensions}) =error("There is no such thing as a dimensionful 1 for a `Dimensions` type, as + is only defined for `Quantity`.")
58
73
59
74
Base.show(io::IO, d::Dimensions) =
60
75
let tmp_io =IOBuffer()
@@ -101,15 +116,17 @@ Base.convert(::Type{Dimensions{R}}, d::Dimensions) where {R} = Dimensions{R}(d)
101
116
Remove the units from a quantity.
102
117
"""
103
118
ustrip(q::Quantity) = q.value
104
-
ustrip(q::Number) = q
119
+
ustrip(::Dimensions) =error("Cannot remove units from a `Dimensions` object.")
120
+
ustrip(q) = q
105
121
106
122
"""
107
123
dimension(q::Quantity)
108
124
109
125
Get the dimensions of a quantity, returning a `Dimensions` object.
0 commit comments