import numpy
from IPython.parallel import Client
dview = Client()[:]; dview
<DirectView [0, 1]>
@dview.parallel(block=True)
def dummy_task(delay):
""" a dummy task that takes 'delay' seconds to finish """
import os, time
print(delay)
t0 = time.time()
pid = os.getpid()
time.sleep(delay)
t1 = time.time()
return [pid, t0, t1]
dummy_task.map(numpy.random.rand(4))
[[25872, 1376270566.9979396, 1376270567.9623675], [25872, 1376270567.9635484, 1376270567.9652116], [25873, 1376270566.9979396, 1376270567.4051127], [25873, 1376270567.4064236, 1376270568.215046]]
%reload_ext version_information
%version_information numpy
Software | Version |
---|---|
Python | 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3] |
IPython | 0.13.2 |
OS | posix [linux] |
numpy | 1.7.1 |
Mon Aug 12 10:22:48 2013 JST |
import numpy
from IPython.parallel import Client
dview = Client()[:]; dview
<DirectView [0, 1]>
@dview.parallel(block=True)
def dummy_task(delay):
""" a dummy task that takes 'delay' seconds to finish """
import os, time
print(delay)
t0 = time.time()
pid = os.getpid()
time.sleep(delay)
t1 = time.time()
return [pid, t0, t1]
dummy_task.map(numpy.random.rand(4))
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-5-20b3daf6aac5> in <module>() ----> 1 dummy_task.map(numpy.random.rand(4)) /usr/local/lib/python3.3/dist-packages/ipython-1.0.0-py3.3.egg/IPython/parallel/client/remotefunction.py in map(self, *sequences) 275 self._mapping = True 276 try: --> 277 ret = self(*sequences) 278 finally: 279 self._mapping = False /usr/local/lib/python3.3/dist-packages/ipython-1.0.0-py3.3.egg/IPython/parallel/client/remotefunction.py in __call__(self, *sequences) /usr/local/lib/python3.3/dist-packages/ipython-1.0.0-py3.3.egg/IPython/parallel/client/remotefunction.py in sync_view_results(f, self, *args, **kwargs) 93 view._in_sync_results = True 94 try: ---> 95 ret = f(self, *args, **kwargs) 96 finally: 97 view._in_sync_results = False /usr/local/lib/python3.3/dist-packages/ipython-1.0.0-py3.3.egg/IPython/parallel/client/remotefunction.py in __call__(self, *sequences) 233 part = self.mapObject.getPartition(seq, index, nparts, maxlen) 234 args.append(part) --> 235 if not any(args): 236 continue 237 ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
in sync results <function ParallelFunction.__call__ at 0x7f172cc80c20>
%reload_ext version_information
%version_information numpy
Software | Version |
---|---|
Python | 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3] |
IPython | 1.0.0 |
OS | posix [linux] |
numpy | 1.7.1 |
Mon Aug 12 10:24:26 2013 JST |