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.one(::Type{D}) where {D<:AbstractDimensions} =D()
269
271
Base.one(::D) where {D<:AbstractDimensions} =one(D)
270
272
271
-
# Additive identities (zero)
273
+
# Additive identities (zero). We have to invalidate these due to different behavior with conversion
272
274
Base.zero(q::Q) where {Q<:UnionAbstractQuantity} =new_quantity(Q, zero(ustrip(q)), dimension(q))
273
275
Base.zero(::AbstractDimensions) =error("There is no such thing as an additive identity for a `AbstractDimensions` object, as + is only defined for `UnionAbstractQuantity`.")
274
276
Base.zero(::Type{<:UnionAbstractQuantity}) =error("Cannot create an additive identity for a `UnionAbstractQuantity` type, as the dimensions are unknown. Please use `zero(::UnionAbstractQuantity)` instead.")
@@ -316,6 +318,10 @@ for (type, _, _) in ABSTRACT_QUANTITY_TYPES, (type2, _, _) in ABSTRACT_QUANTITY_
316
318
Base.convert(::Type{Q}, q::$type) where {T,Q<:$type2{T}} =new_quantity(Q, convert(T, ustrip(q)), dimension(q))
317
319
Base.convert(::Type{Q}, q::$type) where {T,D,Q<:$type2{T,D}} =new_quantity(Q, convert(T, ustrip(q)), convert(D, dimension(q)))
318
320
end
321
+
#TODO: This invalidates some methods. But we have to, because
322
+
# the conversion in `number.jl` has a type assertion step, whereas
323
+
# we want to allow things like `convert(Quantity{Float64}, 1.0u"m")`,
324
+
# with the type for the dimensions being inferred.
319
325
end
320
326
321
327
Base.convert(::Type{D}, d::AbstractDimensions) where {D<:AbstractDimensions} = d
0 commit comments