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.:*(l, r::AbstractQuantity) =new_quantity(typeof(r), l *ustrip(r), copy(dimension(r)))
7
7
Base.:*(l::AbstractDimensions, r) =error("Please use an `AbstractQuantity` for multiplication. You used multiplication on types: $(typeof(l)) and $(typeof(r)).")
8
8
Base.:*(l, r::AbstractDimensions) =error("Please use an `AbstractQuantity` for multiplication. You used multiplication on types: $(typeof(l)) and $(typeof(r)).")
@@ -116,20 +116,20 @@ for f in (:one, :typemin, :typemax)
116
116
if f ==:one# Return empty dimensions, as should be multiplicative identity.
117
117
@eval Base.$f(q::Q) where {Q<:AbstractQuantity} =new_quantity(Q, $f(ustrip(q)), one(dimension(q)))
118
118
else
119
-
@eval Base.$f(q::Q) where {Q<:AbstractQuantity} =new_quantity(Q, $f(ustrip(q)), dimension(q))
119
+
@eval Base.$f(q::Q) where {Q<:AbstractQuantity} =new_quantity(Q, $f(ustrip(q)), copy(dimension(q)))
120
120
end
121
121
end
122
122
Base.one(::Type{D}) where {D<:AbstractDimensions} =D()
123
123
Base.one(::D) where {D<:AbstractDimensions} =one(D)
124
124
125
125
# Additive identities (zero)
126
-
Base.zero(q::Q) where {Q<:AbstractQuantity} =new_quantity(Q, zero(ustrip(q)), dimension(q))
126
+
Base.zero(q::Q) where {Q<:AbstractQuantity} =new_quantity(Q, zero(ustrip(q)), copy(dimension(q)))
127
127
Base.zero(::AbstractDimensions) =error("There is no such thing as an additive identity for a `AbstractDimensions` object, as + is only defined for `AbstractQuantity`.")
128
128
Base.zero(::Type{<:AbstractQuantity}) =error("Cannot create an additive identity for a `AbstractQuantity` type, as the dimensions are unknown. Please use `zero(::AbstractQuantity)` instead.")
129
129
Base.zero(::Type{<:AbstractDimensions}) =error("There is no such thing as an additive identity for a `AbstractDimensions` type, as + is only defined for `AbstractQuantity`.")
130
130
131
131
# Dimensionful 1 (oneunit)
132
-
Base.oneunit(q::Q) where {Q<:AbstractQuantity} =new_quantity(Q, oneunit(ustrip(q)), dimension(q))
132
+
Base.oneunit(q::Q) where {Q<:AbstractQuantity} =new_quantity(Q, oneunit(ustrip(q)), copy(dimension(q)))
133
133
Base.oneunit(::AbstractDimensions) =error("There is no such thing as a dimensionful 1 for a `AbstractDimensions` object, as + is only defined for `AbstractQuantity`.")
134
134
Base.oneunit(::Type{<:AbstractQuantity}) =error("Cannot create a dimensionful 1 for a `AbstractQuantity` type without knowing the dimensions. Please use `oneunit(::AbstractQuantity)` instead.")
135
135
Base.oneunit(::Type{<:AbstractDimensions}) =error("There is no such thing as a dimensionful 1 for a `AbstractDimensions` type, as + is only defined for `AbstractQuantity`.")
0 commit comments