comparison src/LazyTensors/lazy_tensor_operations.jl @ 457:8fb6a5611c7a feature/inflated_tensormapping

Add tests and docs for flatten_tuple
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 21 Oct 2020 20:10:27 +0200
parents 8f4c31e06689
children 41f9cb6ee5a7
comparison
equal deleted inserted replaced
456:8f4c31e06689 457:8fb6a5611c7a
251 """ 251 """
252 function slice_tuple(t,::Val{L},::Val{U}) where {L,U} 252 function slice_tuple(t,::Val{L},::Val{U}) where {L,U}
253 return ntuple(i->t[i+L-1], U-L+1) 253 return ntuple(i->t[i+L-1], U-L+1)
254 end 254 end
255 255
256 """
257 flatten_tuple(t)
258
259 Takes a nested tuple and flattens the whole structure
260 """
256 flatten_tuple(t::NTuple{N, Number} where N) = t 261 flatten_tuple(t::NTuple{N, Number} where N) = t
257 flatten_tuple(t::Tuple) = ((flatten_tuple.(t)...)...,) # simplify? 262 flatten_tuple(t::Tuple) = ((flatten_tuple.(t)...)...,) # simplify?
258 flatten_tuple(ts::Vararg) = flatten_tuple(ts) 263 flatten_tuple(ts::Vararg) = flatten_tuple(ts)