Beispiel #1
0
    def __call__(self, *args, **kwargs):
        """
        Create a Sequence using a parallel ExecutionEngine.

        If args has more than one argument then the argument list becomes the sequence.

        If args[0] is primitive, a sequence wrapping it is created.

        If args[0] is a list, tuple, iterable, or Sequence it is wrapped as a Sequence.

        :param args: Sequence to wrap
        :return: Wrapped sequence
        """
        processes = kwargs.get('processes') or self.processes
        partition_size = kwargs.get('partition_size') or self.partition_size
        engine = ParallelExecutionEngine(processes=processes,
                                         partition_size=partition_size)
        if len(args) == 0:
            raise TypeError(
                'pseq() takes at least 1 argument ({0} given)'.format(
                    len(args)))
        elif len(args) > 1:
            return Sequence(list(args), engine=engine)
        elif is_primitive(args[0]):
            return Sequence([args[0]], engine=engine)
        else:
            return Sequence(args[0], engine=engine)
Beispiel #2
0
    def __call__(self, *args, **kwargs):
        """
        Create a Sequence using a parallel ExecutionEngine.

        If args has more than one argument then the argument list becomes the sequence.

        If args[0] is primitive, a sequence wrapping it is created.

        If args[0] is a list, tuple, iterable, or Sequence it is wrapped as a Sequence.

        :param args: Sequence to wrap
        :return: Wrapped sequence
        """
        processes = kwargs.get('processes') or self.processes
        partition_size = kwargs.get('partition_size') or self.partition_size
        engine = ParallelExecutionEngine(processes=processes, partition_size=partition_size)
        return self._parse_args(args, engine, 'pseq() takes at least 1 argument ({0} given)')