|
47 | 47 | # Assorted calls found by Aqua: ################################################
|
48 | 48 | ################################################################################
|
49 | 49 |
|
50 |
| -function Complex(q::AbstractRealQuantity) |
51 |
| - @assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead." |
52 |
| - return Complex(ustrip(q)) |
53 |
| -end |
54 |
| -function Complex{T}(q::AbstractRealQuantity) where {T<:Real} |
55 |
| - @assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead." |
56 |
| - return Complex{T}(ustrip(q)) |
57 |
| -end |
58 |
| -function Bool(q::AbstractRealQuantity) |
59 |
| - @assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead." |
60 |
| - return Bool(ustrip(q)) |
61 |
| -end |
62 | 50 | for type in (Signed, Float64, Float32, Rational), op in (:flipsign, :copysign)
|
63 | 51 | @eval function Base.$(op)(x::$type, y::AbstractRealQuantity)
|
64 | 52 | return $(op)(x, ustrip(y))
|
65 | 53 | end
|
66 | 54 | end
|
67 |
| -for type in (Complex, Complex{Bool}) |
| 55 | +for type in (:(Complex), :(Complex{Bool})) |
68 | 56 | @eval begin
|
69 | 57 | function Base.:*(l::$type, r::AbstractRealQuantity)
|
70 | 58 | new_quantity(typeof(r), l * ustrip(r), dimension(r))
|
71 | 59 | end
|
72 | 60 | function Base.:*(l::AbstractRealQuantity, r::$type)
|
73 | 61 | new_quantity(typeof(l), ustrip(l) * r, dimension(l))
|
74 | 62 | end
|
| 63 | + function $type(q::AbstractRealQuantity) |
| 64 | + @assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead." |
| 65 | + return $type(ustrip(q)) |
| 66 | + end |
75 | 67 | end
|
76 | 68 | end
|
| 69 | +function Bool(q::AbstractRealQuantity) |
| 70 | + @assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead." |
| 71 | + return Bool(ustrip(q)) |
| 72 | +end |
77 | 73 | function Base.:/(l::Complex, r::AbstractRealQuantity)
|
78 | 74 | new_quantity(typeof(r), l / ustrip(r), inv(dimension(r)))
|
79 | 75 | end
|
|
0 commit comments