Esempio n. 1
0
    def __new__(cls, variables, expr):
        if not is_Tuple(variables) or len(variables) != 3:
            raise TypeError('variables is not a 3-Tuple: %s'%variables)
        if not is_Tuple(expr) or len(expr) != 3:
            raise TypeError('expr is not a 3-Tuple: %s'%expr)

        return Functor.__new__(cls, variables, expr)
Esempio n. 2
0
    def __new__(cls, *paths, **kwargs):
        evaluate = kwargs.pop('evaluate', global_evaluate[0])

        if any(not isinstance(pth, Path) for pth in paths):
            raise TypeError
        if len(paths) != 0 and len(set(pth.length for pth in paths)) != 1:
            raise ValueError

        nres = sum(pth.nres for pth in paths)
        if evaluate:
            paths = cls.reduce(paths)

        if len(paths) == 0:
            return IdentityPath(nres)
        elif len(paths) == 1:
            return paths[0]
        else:
            return Functor.__new__(cls, *paths)
Esempio n. 3
0
    def __new__(cls, path, start, stop, **kwargs):
        evaluate = kwargs.pop('evaluate', global_evaluate[0])

        if not isinstance(path, Path):
            raise TypeError
        stop = sympify(stop) if stop is not None else path.length
        start = sympify(start) if start is not None else S.Zero
        if (stop not in Interval(0, path.length) or
            start not in Interval(0, path.length) or
            stop < start):
            raise IndexError

        if evaluate:
            if start == 0 and stop == path.length:
                sliced_path = path
            elif start == stop:
                sliced_path = IdentityPath(path.nres)
            else:
                sliced_path = path._slice(start, stop)

        if sliced_path is not None:
            return sliced_path
        else:
            return Functor.__new__(cls, path, start, stop)
Esempio n. 4
0
 def __new__(cls, tvec=zeros3, rquat=Mat([1,0,0,0]), parity=1):
     tvec = Mat(tvec)
     rquat = Mat(rquat)
     parity = sign(parity)
     return Functor.__new__(cls, tvec, rquat, parity)
Esempio n. 5
0
 def __new__(cls, matrix=eye(3), vector=zeros3):
     matrix = Mat(matrix)
     vector = Mat(vector)
     return Functor.__new__(cls, matrix, vector)
Esempio n. 6
0
 def __new__(cls, nres, **kwargs):
     return Functor.__new__(cls, sympify(nres))