Skip to content

Commit 914390b

Browse files
committed
Add ustrip and dimension for arrays
1 parent 17c9348 commit 914390b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/utils.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Remove the units from a quantity.
148148
"""
149149
ustrip(q::AbstractQuantity) = q.value
150150
ustrip(::AbstractDimensions) = error("Cannot remove units from an `AbstractDimensions` object.")
151+
ustrip(aq::AbstractArray{<:AbstractQuantity}) = ustrip.(aq)
151152
ustrip(q) = q
152153

153154
"""
@@ -157,6 +158,7 @@ Get the dimensions of a quantity, returning an `AbstractDimensions` object.
157158
"""
158159
dimension(q::AbstractQuantity) = q.dimensions
159160
dimension(d::AbstractDimensions) = d
161+
dimension(aq::AbstractArray{<:AbstractQuantity}) = allequal(dimension.(aq)) ? dimension(first(aq)) : throw(DimensionError(aq[begin], aq[begin+1:end]))
160162

161163
"""
162164
ulength(q::AbstractQuantity)

0 commit comments

Comments
 (0)