Skip to content

Commit

Permalink
Add missing method for pow between quantities
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Nov 30, 2023
1 parent 7f05f5d commit 50988fd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ end
Base.:-(l::UnionAbstractQuantity) = new_quantity(typeof(l), -ustrip(l), dimension(l))

# Combining different abstract types
for op in (:*, :/, :+, :-, :atan, :atand, :copysign, :flipsign, :div, :mod),
for op in (:*, :/, :+, :-, :^, :atan, :atand, :copysign, :flipsign, :div, :mod),
(t1, _, _) in ABSTRACT_QUANTITY_TYPES,
(t2, _, _) in ABSTRACT_QUANTITY_TYPES

Expand Down Expand Up @@ -130,6 +130,10 @@ for (type, _, _) in ABSTRACT_QUANTITY_TYPES
iszero(dimension(l)) || throw(DimensionError(l))
return new_quantity(typeof(l), ustrip(l)^r, dimension(l))
end
function Base.:^(l::$type, r::$type)
iszero(dimension(r)) || throw(DimensionError(r))
return l ^ ustrip(r)
end
end
end
@inline Base.literal_pow(::typeof(^), l::AbstractDimensions, ::Val{p}) where {p} = map_dimensions(Base.Fix1(*, p), l)
Expand Down

0 comments on commit 50988fd

Please sign in to comment.