This code
import numpy as np def some_method(y, threshold): print type(y), y.shape, y.dtype c = np.zeros(y.shape) c[y > threshold] = 1
Results in
<type 'numpy.ndarray'> (484L,) [('target', '<f8')] DeprecationWarning: using a boolean instead of an integer will result in an error in the future c[y > threshold] = 1
I cannot find anything on Google or in the numpy release notes. I assume this is about indexing using boolean elements? I do not understand how this can lead to an error in the future, how can I fix it?
Python 2.7.6 (default, November 10, 2013 7:24:24 PM) [MSC v.1500 64 bit (AMD64)] on win32
CD Version: 1.8.0
EDIT: A print statement has been added to the code to show that the array is an ndarray
EDIT2: From the comments it became clear that this is happening because y is an array of structures, and the correct way to do the verification is y['target'] > threshold . However, y can have multiple columns or even different column names, is there a way to do this flexibly with structured arrays?
source share