def untake(x, idx, template): result = list(zeros_like(template)) result[idx] = x return tuple(result)
def iadd_any(other, self): array = zeros_like(self.template) if other is 0 else other array[self.idx] += self.val return array
def zeros_like(self): return {k : zeros_like(v) for k, v in six.iteritems(getval(self))}
def zeros_like(value): return tuple([zeros_like(item) for item in getval(value)])
def dict_untake(x, idx, template): result = dict(zeros_like(template)) result[idx] = x return result
def list_untake(x, idx, template): result = list(zeros_like(template)) result[idx] = x return result
def zeros_like(value): return [zeros_like(item) for item in getval(value)]
def tuple_untake(x, idx, template): result = list(zeros_like(template)) result[idx] = x return tuple(result)
def zeros_like(self): return {k: zeros_like(v) for k, v in six.iteritems(getval(self))}