You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Tue, Apr 10, 2018 at 11:18 AM, Philipp Rudiger ***@***.***> wrote:
Comparing a dask Series with a NumPy scalar or 0D array fails in certain
cases. Here is a minimal reproducible example:
import dask.dataframe as ddimport pandas as pd
np.float64(5.2) >= dd.from_array(np.arange(10))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-18-d905075c0565> in <module>()
1
----> 2 np.float64(10) >= dd.from_array(np.arange(10))
~/miniconda/envs/anacondaviz/lib/python3.6/site-packages/dask/dataframe/core.py in __array_wrap__(self, array, context)
1704 def __array_wrap__(self, array, context=None):
1705 if isinstance(context, tuple) and len(context) > 0:
-> 1706 index = context[1][0].index
1707
1708 return pd.Series(array, index=index, name=self.name)
AttributeError: 'numpy.ndarray' object has no attribute 'index'
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3392>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASszHQV1Rp5uH9jCguuPd_Yt7-FYMb-ks5tnNtpgaJpZM4TOlMB>
.
It looks like np.float64(5.2) is getting converted to a 0-dimensional array (i.e. np.array(5.2)) when inputted into __array_ufunc__. Because of this, the isinstance check for Number fails
Activity
mrocklin commentedon Apr 12, 2018
martindurant commentedon Apr 12, 2018
I also get an error for the same code, but not the same error. Running from master.
jrbourbeau commentedon Apr 23, 2018
I'm getting the same error as @martindurant.
It looks like
np.float64(5.2)is getting converted to a 0-dimensional array (i.e.np.array(5.2)) when inputted into__array_ufunc__. Because of this, theisinstancecheck forNumberfailsdask/dask/dataframe/core.py
Lines 347 to 349 in b64e694
and an error is thrown.
I can look into adding an extra check in
__array_ufunc__for 0-dimensionalnp.ndarraysmrocklin commentedon Apr 24, 2018
jrbourbeau commentedon Apr 24, 2018
I can take this one up