def evalArg(self, arg): if type(arg) == list: return [self.evalArg(a) for a in arg] elif type(arg) == Size: return Size(self.evalArg(arg.size), arg.isRelative) else: try: return float(arg.subs([('rand', random())])) except: return arg
def repeatN(self, axis, n): # just split with n split sections each of relative size 1 return self.split(axis, [Size(1, True)] * n)
def repeat(self, axis, size): numRepeats = ceil(self.sizeDict[axis] / size) size = Size(1, True) # just split with numRepeats split sections each of relative size 1 return self.split(axis, [size] * numRepeats)
def size(self, p): return Size(p.expr, True)
def size(self, p): try: return Size(self.vars[p.IDENT], True) except LookupError: raise RuntimeError(f'Undefined variable {p.IDENT!r}')
def size(self, p): return Size(p.number, True)
def size(self, p): return Size(p.expr, False)