Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPython parallel map fails on numpy arrays #4020

Closed
samuela opened this issue Aug 14, 2013 · 0 comments · Fixed by #4021
Closed

IPython parallel map fails on numpy arrays #4020

samuela opened this issue Aug 14, 2013 · 0 comments · Fixed by #4021
Labels
Milestone

Comments

@samuela
Copy link
Contributor

samuela commented Aug 14, 2013

The following fails:

import pandas as pd
import numpy as np

from IPython.parallel import Client
c = Client()
v = c[:]

v.map_sync(lambda x: x, np.arange(101))

with the error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-71ded66ea5e0> in <module>()
----> 1 X, Y, index = get_XY(indicators, ticker='DIA', balance=False)

/Users/samuelainsworth/Development/Finance Research/suspicious_classifier.py in get_XY(indicators, ticker, lamb, balance, verbose)
    154     ### Buys
    155     # Collect features for all buys and associate with dates
--> 156     buy_features = zip(buys, v.map_sync(collect_features, buys))
    157 
    158     # drop examples where we don't features

/usr/local/lib/python2.7/site-packages/IPython/parallel/client/view.pyc in map_sync(self, f, *sequences, **kwargs)
    365             raise TypeError("map_sync doesn't take a `block` keyword argument.")
    366         kwargs['block'] = True
--> 367         return self.map(f,*sequences,**kwargs)
    368 
    369     def imap(self, f, *sequences, **kwargs):

/usr/local/lib/python2.7/site-packages/IPython/parallel/client/view.pyc in map(self, f, *sequences, **kwargs)

/usr/local/lib/python2.7/site-packages/IPython/parallel/client/view.pyc in sync_results(f, self, *args, **kwargs)
     61     self._in_sync_results = True
     62     try:
---> 63         ret = f(self, *args, **kwargs)
     64     finally:
     65         self._in_sync_results = False

/usr/local/lib/python2.7/site-packages/IPython/parallel/client/view.pyc in map(self, f, *sequences, **kwargs)
    613         assert len(sequences) > 0, "must have some sequences to map onto!"
    614         pf = ParallelFunction(self, f, block=block, **kwargs)
--> 615         return pf.map(*sequences)
    616 
    617     @sync_results

/usr/local/lib/python2.7/site-packages/IPython/parallel/client/remotefunction.pyc in map(self, *sequences)
    275         self._mapping = True
    276         try:
--> 277             ret = self(*sequences)
    278         finally:
    279             self._mapping = False

/usr/local/lib/python2.7/site-packages/IPython/parallel/client/remotefunction.pyc in __call__(self, *sequences)

/usr/local/lib/python2.7/site-packages/IPython/parallel/client/remotefunction.pyc in sync_view_results(f, self, *args, **kwargs)
     89     view = self.view
     90     if view._in_sync_results:
---> 91         return f(self, *args, **kwargs)
     92     print 'in sync results', f
     93     view._in_sync_results = True

/usr/local/lib/python2.7/site-packages/IPython/parallel/client/remotefunction.pyc 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()
@minrk minrk closed this as completed in 04aa452 Aug 15, 2013
markvoorhies pushed a commit to markvoorhies/ipython that referenced this issue Dec 3, 2013
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Fix parallel.client.View map() on numpy arrays

closes ipython#4020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant