Mercurial > repos > public > sbplib_julia
diff src/LazyTensors/lazy_tensor_operations.jl @ 456:8f4c31e06689 feature/inflated_tensormapping
Add docs and tests for slice_tuple
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 21 Oct 2020 19:53:36 +0200 |
parents | b86312d14873 |
children | 8fb6a5611c7a |
line wrap: on
line diff
--- a/src/LazyTensors/lazy_tensor_operations.jl Wed Oct 21 16:29:59 2020 +0200 +++ b/src/LazyTensors/lazy_tensor_operations.jl Wed Oct 21 19:53:36 2020 +0200 @@ -239,6 +239,16 @@ return (view_index, inner_index) end +# TODO: Can this be replaced by something more elegant while still being type stable? 2020-10-21 +# See: +# https://github.com/JuliaLang/julia/issues/34884 +# https://github.com/JuliaLang/julia/issues/30386 +""" + slice_tuple(t, Val(l), Val(u)) + +Get a slice of a tuple in a type stable way. +Equivalent to t[l:u] but type stable. +""" function slice_tuple(t,::Val{L},::Val{U}) where {L,U} return ntuple(i->t[i+L-1], U-L+1) end