{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/12316","repository_url":"https://api.github.com/repos/numpy/numpy","labels_url":"https://api.github.com/repos/numpy/numpy/issues/12316/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/12316/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/12316/events","html_url":"https://github.com/numpy/numpy/issues/12316","id":376991638,"node_id":"MDU6SXNzdWUzNzY5OTE2Mzg=","number":12316,"title":"The `argmin` method of the masked array is not working properly.","user":{"login":"kuzand","id":15230238,"node_id":"MDQ6VXNlcjE1MjMwMjM4","avatar_url":"https://avatars3.githubusercontent.com/u/15230238?v=4","gravatar_id":"","url":"https://api.github.com/users/kuzand","html_url":"https://github.com/kuzand","followers_url":"https://api.github.com/users/kuzand/followers","following_url":"https://api.github.com/users/kuzand/following{/other_user}","gists_url":"https://api.github.com/users/kuzand/gists{/gist_id}","starred_url":"https://api.github.com/users/kuzand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuzand/subscriptions","organizations_url":"https://api.github.com/users/kuzand/orgs","repos_url":"https://api.github.com/users/kuzand/repos","events_url":"https://api.github.com/users/kuzand/events{/privacy}","received_events_url":"https://api.github.com/users/kuzand/received_events","type":"User","site_admin":false},"labels":[{"id":16917467,"node_id":"MDU6TGFiZWwxNjkxNzQ2Nw==","url":"https://api.github.com/repos/numpy/numpy/labels/component:%20numpy.ma","name":"component: numpy.ma","color":"009800","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-11-02T22:52:23Z","updated_at":"2018-11-03T22:01:22Z","closed_at":null,"author_association":"NONE","body":"The `argmin` method of the masked array is not working properly.\r\n\r\n<!-- A short code example that reproduces the problem/missing feature. It should be\r\nself-contained, i.e., possible to run as-is via 'python myproblem.py' -->\r\n\r\n```python\r\nimport numpy as np\r\n\r\na = np.ma.array([1, 2, 1e+21, 1e+22], mask=[1, 1, 0, 0])\r\nd = a.filled().view(np.ndarray)\r\n\r\nprint(d.argmin())  # 0\r\nprint(a.argmin())  # 2\r\n```\r\nHowever, the `argmin` method is implemented by computing `d` and then returning `d.argmin()`:\r\n```python\r\n# https://github.com/numpy/numpy/blob/master/numpy/ma/core.py\r\ndef argmin(self, axis=None, fill_value=None, out=None):\r\n    if fill_value is None:\r\n        fill_value = minimum_fill_value(self)\r\n    d = self.filled(fill_value).view(ndarray)\r\n    return d.argmin(axis, out=out)\r\n```\r\n\r\n So why I am getting two different results?\r\n\r\nOn the other hand, when the unmasked items are all inf's, then the `argmin` returns always 0:\r\n```python\r\na = np.ma.array([1, 2, np.inf, np.inf], mask=[1, 1, 0, 0])\r\nd = a.filled().view(np.ndarray)\r\n\r\nprint(d.argmin())  # 0\r\nprint(a.argmin())  # 0\r\n```\r\nBut in both cases `fill_value=1e+20` is smaller than `a[2] = 1e+21` and `a[2] = np.inf`. In any case, the output I would expect is 2 for both examples, since I don't want to compare the unmasked items with the masked items.\r\n\r\n### Numpy/Python version information:\r\n\r\n<!-- Output from 'import sys, numpy; print(numpy.__version__, sys.version)' -->\r\n1.15.3 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]\r\n"},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/435624318","html_url":"https://github.com/numpy/numpy/issues/12316#issuecomment-435624318","issue_url":"https://api.github.com/repos/numpy/numpy/issues/12316","id":435624318,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTYyNDMxOA==","user":{"login":"eric-wieser","id":425260,"node_id":"MDQ6VXNlcjQyNTI2MA==","avatar_url":"https://avatars3.githubusercontent.com/u/425260?v=4","gravatar_id":"","url":"https://api.github.com/users/eric-wieser","html_url":"https://github.com/eric-wieser","followers_url":"https://api.github.com/users/eric-wieser/followers","following_url":"https://api.github.com/users/eric-wieser/following{/other_user}","gists_url":"https://api.github.com/users/eric-wieser/gists{/gist_id}","starred_url":"https://api.github.com/users/eric-wieser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eric-wieser/subscriptions","organizations_url":"https://api.github.com/users/eric-wieser/orgs","repos_url":"https://api.github.com/users/eric-wieser/repos","events_url":"https://api.github.com/users/eric-wieser/events{/privacy}","received_events_url":"https://api.github.com/users/eric-wieser/received_events","type":"User","site_admin":false},"created_at":"2018-11-03T22:01:22Z","updated_at":"2018-11-03T22:01:22Z","author_association":"MEMBER","body":"I don't think that approach works with an axis argument"}}
{"actor":{"display_login":"eric-wieser"}}