(cls, args)
Evaluates the direct product.
Evaluates the direct product.
Evaluates the direct product .
def eval(cls, args):
        """Evaluates the direct product."""
        new_args = []
        recall = False
        #flatten arguments
        for arg in args:
            if isinstance(arg, DirectSumHilbertSpace):
                new_args.extend(arg.args)
                recall = True
            elif isinstance(arg, HilbertSpace):
                new_args.append(arg)
            else:
                raise TypeError('Hilbert spaces can only be summed with other \
                Hilbert spaces: %r' % arg)
        if recall:
            return DirectSumHilbertSpace(*new_args)
        else:
            return None
def eval ( cls , args ) : new_args = [ ] recall = False #flatten arguments for arg in args : if isinstance ( arg , DirectSumHilbertSpace ) : new_args . extend ( arg . args ) recall = True elif isinstance ( arg , HilbertSpace ) : new_args . append ( arg ) else : raise TypeError ( 'Hilbert spaces can only be summed with other \
                Hilbert spaces: %r' % arg ) if recall : return DirectSumHilbertSpace ( * new_args ) else : return None