{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/6784","labels_url":"https://api.github.com/repos/numpy/numpy/issues/6784/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/6784/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/6784/events","html_url":"https://github.com/numpy/numpy/issues/6784","id":120688521,"number":6784,"title":"\"FutureWarning: elementwise comparison failed\" makes it hard to check whether a value exists in an array","user":{"login":"MarkMoulton","id":3900685,"avatar_url":"https://avatars.githubusercontent.com/u/3900685?v=3","gravatar_id":"","url":"https://api.github.com/users/MarkMoulton","html_url":"https://github.com/MarkMoulton","followers_url":"https://api.github.com/users/MarkMoulton/followers","following_url":"https://api.github.com/users/MarkMoulton/following{/other_user}","gists_url":"https://api.github.com/users/MarkMoulton/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkMoulton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkMoulton/subscriptions","organizations_url":"https://api.github.com/users/MarkMoulton/orgs","repos_url":"https://api.github.com/users/MarkMoulton/repos","events_url":"https://api.github.com/users/MarkMoulton/events{/privacy}","received_events_url":"https://api.github.com/users/MarkMoulton/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/numpy/numpy/labels/component:%20numpy.core","name":"component: numpy.core","color":"ff0000"},{"url":"https://api.github.com/repos/numpy/numpy/labels/Defect","name":"Defect","color":"444444"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/numpy/numpy/milestones/39","html_url":"https://github.com/numpy/numpy/milestones/1.10.2%20release","labels_url":"https://api.github.com/repos/numpy/numpy/milestones/39/labels","id":1353924,"number":39,"title":"1.10.2 release","description":"","creator":{"login":"charris","id":77272,"avatar_url":"https://avatars.githubusercontent.com/u/77272?v=3","gravatar_id":"","url":"https://api.github.com/users/charris","html_url":"https://github.com/charris","followers_url":"https://api.github.com/users/charris/followers","following_url":"https://api.github.com/users/charris/following{/other_user}","gists_url":"https://api.github.com/users/charris/gists{/gist_id}","starred_url":"https://api.github.com/users/charris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charris/subscriptions","organizations_url":"https://api.github.com/users/charris/orgs","repos_url":"https://api.github.com/users/charris/repos","events_url":"https://api.github.com/users/charris/events{/privacy}","received_events_url":"https://api.github.com/users/charris/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":78,"state":"open","created_at":"2015-10-13T19:48:01Z","updated_at":"2015-12-07T22:04:58Z","due_on":null,"closed_at":null},"comments":16,"created_at":"2015-12-07T02:59:14Z","updated_at":"2015-12-07T22:46:58Z","closed_at":null,"body":"I have innumerable places in my code where I test whether a value exists in an array when I don't know either the type of the value or the dtype of the array.  In previous numpy versions (I'm at 1.10.1), mismatched types return False.  Now they generate a FutureWarning.\r\n```Python\r\na = np.arange(5)\r\n\r\n'x' in a\r\n__main__:1: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\r\nOut[78]: False\r\n```\r\nThe same applies when comparing arrays elementwise:\r\n```Python\r\na = np.arange(3)\r\n\r\nb = np.arange(3).astype(str)\r\n\r\na == b\r\n__main__:1: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\r\nOut[106]: False\r\n```\r\nI know the new behavior is deliberate, but I think practicality has been sacrificed for purity.\r\n\r\nIn the example above, it seems reasonable that ```'x' in a``` returns False, because being a string type automatically means 'x' cannot belong to an array of a different type.  It also makes sense that two arrays are not equal if they have different dtypes.\r\n\r\nSo how do I repair my code?  Do I add type checking for all value checks?  Do I convert the array to a list first?  Do I convert to an object dtype?  Do I use Try/Except?  I don't like any of these options and am having trouble thinking of a clean fix.  \r\n\r\nFor what it's worth, I view this change as a serious regression."},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/162694012","html_url":"https://github.com/numpy/numpy/issues/6784#issuecomment-162694012","issue_url":"https://api.github.com/repos/numpy/numpy/issues/6784","id":162694012,"user":{"login":"njsmith","id":609896,"avatar_url":"https://avatars.githubusercontent.com/u/609896?v=3","gravatar_id":"","url":"https://api.github.com/users/njsmith","html_url":"https://github.com/njsmith","followers_url":"https://api.github.com/users/njsmith/followers","following_url":"https://api.github.com/users/njsmith/following{/other_user}","gists_url":"https://api.github.com/users/njsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/njsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njsmith/subscriptions","organizations_url":"https://api.github.com/users/njsmith/orgs","repos_url":"https://api.github.com/users/njsmith/repos","events_url":"https://api.github.com/users/njsmith/events{/privacy}","received_events_url":"https://api.github.com/users/njsmith/received_events","type":"User","site_admin":false},"created_at":"2015-12-07T22:46:58Z","updated_at":"2015-12-07T22:46:58Z","body":"I guess it might be nice to suppress the warning for `string in array` if there's a clean way to do it, but let's not hold up 1.10.2 waiting for this."}}