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
@shoyer Hi, I was looking into this bug and found that it works fine in python2 but throws an error in python3. The reason is, the function PyInt_Check is overrided in python3 , and it returns false when we check for raw integers.
The overrided PyInt_Check is returning false, as it internally checks whether the value returns true for PyLong_Checkhere.
What do you suggest should be done here ? ( I would like to work on this bugfix)
P.S. : We also get the same error when we call np.datetime (Due to the same flow)
It looks like PyArray_IsScalar(object, Integer) may be the right check for NumPy integer scalars, but I'm not 100% sure since the documentation for that function is rather terse.
@seberg How do you do type checks for integers in indexing operations?
I only check if it can cast with "same type" to intp IIRC. For scalars, I try PyArray_PyIntAsIntp, which I changed to raise an error when operator.index fails or it is a bool.
Activity
shoyer commentedon May 11, 2016
Yep, this is definitely a bug. To reproduce:
yashmehrotra commentedon May 11, 2016
@shoyer Hi, I was looking into this bug and found that it works fine in python2 but throws an error in python3. The reason is, the function
PyInt_Checkis overrided in python3 , and it returnsfalsewhen we check for raw integers.The overrided
PyInt_Checkis returning false, as it internally checks whether the value returnstrueforPyLong_Checkhere.What do you suggest should be done here ? ( I would like to work on this bugfix)
P.S. : We also get the same error when we call
np.datetime(Due to the same flow)shoyer commentedon May 11, 2016
It looks like
PyArray_IsScalar(object, Integer)may be the right check for NumPy integer scalars, but I'm not 100% sure since the documentation for that function is rather terse.@seberg How do you do type checks for integers in indexing operations?
seberg commentedon May 11, 2016
I only check if it can cast with "same type" to intp IIRC. For scalars, I try
PyArray_PyIntAsIntp, which I changed to raise an error whenoperator.indexfails or it is a bool.seberg commentedon May 11, 2016
There is an unfortunate thing here, since intp is too small for datetime on some platforms, you cannot use the
operator.indextrick here I guess :(.