Skip to content

Commit

Permalink
Merge pull request #95 from Keno/mbauman/unsafe-ranges
Browse files Browse the repository at this point in the history
Forward unsafe_getindex for SIRanges to the Range
  • Loading branch information
timholy committed Oct 7, 2016
2 parents d25c434 + 99d1fa0 commit 97a3394
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/SIUnits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module SIUnits
unit{T,m,kg,s,A,K,mol,cd,rad,sr}(x::SIRanges{T,m,kg,s,A,K,mol,cd,rad,sr}) = SIUnit{m,kg,s,A,K,mol,cd,rad,sr}()
quantity{T,m,kg,s,A,K,mol,cd,rad,sr}(x::SIRanges{T,m,kg,s,A,K,mol,cd,rad,sr}) = SIQuantity{T,m,kg,s,A,K,mol,cd,rad,sr}

import Base: length, getindex, next, float, show, start, step, last, done, first, eltype, one, zero
import Base: length, getindex, unsafe_getindex, next, float, show, start, step, last, done, first, eltype, one, zero

one(x::SIQuantity) = one(x.val)
one{T,m,kg,s,A,K,mol,cd,rad,sr}(::Type{SIQuantity{T,m,kg,s,A,K,mol,cd,rad,sr}}) = one(T)
Expand All @@ -53,6 +53,8 @@ module SIUnits
show{T<:UnitRange}(io::IO, r::SIRange{T}) = print(io, first(r),':',last(r))
getindex(r::SIRanges,i::Integer) = (quantity(r)(getindex(r.val,i)))
getindex{T<:SIRanges}(r::T,i::Range) = T(getindex(r.val,i))
unsafe_getindex(r::SIRanges,i::Integer) = (quantity(r)(unsafe_getindex(r.val,i)))
unsafe_getindex{T<:SIRanges}(r::T,i::Range) = T(unsafe_getindex(r.val,i))
function next(r::SIRanges, i)
v, j = next(r.val,i)
to_q(quantity(r),v), j
Expand Down

0 comments on commit 97a3394

Please sign in to comment.