ipython/ipython — Issue #1401: numpy arrays cannot be used with DirectView.apply()
Author: disjunctor
Created: 2012-02-13 03:32:46+00:00
State: open

When using IPython parallel module, numpy arrays cannot be used with apply() function.

Tested on:
Python 3.2.1 (default, Jul 18 2011, 16:24:40) [GCC]
IPython 0.13.dev, 0.12

```python
from IPython.parallel import Client
import numpy

def test(arr):
return arr[0]

if __name__ == '__main__':
dview = Client(profile = 'local')
arr = numpy.arange(10)

res = dview[0].apply(test, arr)
print(res.get())
```

The following error occurs:

```python
Traceback (most recent call last):
File "/home/aver/git/sdp/test(emd).py", line 21, in
res = call_emd(lst, parallel_profile = 'local')
File "/home/aver/git/sdp/sdp/decorator/parallel.py", line 16, in wrapper
async_result.append(engines_view.apply_sync(func, i, **kwargs))
File "", line 2, in apply_sync
File "/usr/local/lib/python3.2/site-packages/ipython-0.13.dev-py3.2.egg/IPython/parallel/client/view.py", line 70, in spin_after
ret = f(self, *args, **kwargs)
File "/usr/local/lib/python3.2/site-packages/ipython-0.13.dev-py3.2.egg/IPython/parallel/client/view.py", line 227, in apply_sync
return self._really_apply(f, args, kwargs, block=True)
File "", line 2, in _really_apply
File "/usr/local/lib/python3.2/site-packages/ipython-0.13.dev-py3.2.egg/IPython/parallel/client/view.py", line 59, in sync_results
ret = f(self, *args, **kwargs)
File "", line 2, in _really_apply
File "/usr/local/lib/python3.2/site-packages/ipython-0.13.dev-py3.2.egg/IPython/parallel/client/view.py", line 48, in save_ids
ret = f(self, *args, **kwargs)
File "/usr/local/lib/python3.2/site-packages/ipython-0.13.dev-py3.2.egg/IPython/parallel/client/view.py", line 997, in _really_apply
return ar.get()
File "/usr/local/lib/python3.2/site-packages/ipython-0.13.dev-py3.2.egg/IPython/parallel/client/asyncresult.py", line 104, in get
raise self._exception
File "/usr/local/lib/python3.2/site-packages/ipython-0.13.dev-py3.2.egg/IPython/parallel/client/asyncresult.py", line 129, in wait
raise r
IPython.parallel.error.RemoteError: NameError(global name 'buffer' is not defined)
Traceback (most recent call last):
File "/usr/local/lib/python3.2/site-packages/ipython-0.13.dev-py3.2.egg/IPython/parallel/engine/streamkernel.py", line 320, in apply_request
f,args,kwargs = unpack_apply_message(bufs, working, copy=False)
File "/usr/local/lib/python3.2/site-packages/ipython-0.13.dev-py3.2.egg/IPython/parallel/util.py", line 305, in unpack_apply_message
sa.data = buffer(m)
NameError: global name 'buffer' is not defined
```