Mercurial > repos > public > sbplib_julia
diff src/LazyTensors/tuple_manipulation.jl @ 1355:102ebdaf7c11 feature/variable_derivatives
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 08 Feb 2023 21:21:28 +0100 |
parents | 07c213167f7c |
children | 5bfb182e24dc |
line wrap: on
line diff
--- a/src/LazyTensors/tuple_manipulation.jl Fri Feb 03 22:50:42 2023 +0100 +++ b/src/LazyTensors/tuple_manipulation.jl Wed Feb 08 21:21:28 2023 +0100 @@ -75,7 +75,11 @@ flatten_tuple(t::Tuple) = ((flatten_tuple.(t)...)...,) # simplify? flatten_tuple(ts::Vararg) = flatten_tuple(ts) +""" + left_pad_tuple(t, val, N) +Left pad the tuple `t` to length `N` using the value `val`. +""" function left_pad_tuple(t, val, N) if N < length(t) throw(DomainError(N, "Can't pad tuple of length $(length(t)) to $N elements")) @@ -85,6 +89,11 @@ return (padding..., t...) end +""" + right_pad_tuple(t, val, N) + +Right pad the tuple `t` to length `N` using the value `val`. +""" function right_pad_tuple(t, val, N) if N < length(t) throw(DomainError(N, "Can't pad tuple of length $(length(t)) to $N elements"))