{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/6454","labels_url":"https://api.github.com/repos/numpy/numpy/issues/6454/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/6454/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/6454/events","html_url":"https://github.com/numpy/numpy/issues/6454","id":110924004,"number":6454,"title":"copysign fails to work inplace with integer arrays","user":{"login":"ev-br","id":2133832,"avatar_url":"https://avatars.githubusercontent.com/u/2133832?v=3","gravatar_id":"","url":"https://api.github.com/users/ev-br","html_url":"https://github.com/ev-br","followers_url":"https://api.github.com/users/ev-br/followers","following_url":"https://api.github.com/users/ev-br/following{/other_user}","gists_url":"https://api.github.com/users/ev-br/gists{/gist_id}","starred_url":"https://api.github.com/users/ev-br/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ev-br/subscriptions","organizations_url":"https://api.github.com/users/ev-br/orgs","repos_url":"https://api.github.com/users/ev-br/repos","events_url":"https://api.github.com/users/ev-br/events{/privacy}","received_events_url":"https://api.github.com/users/ev-br/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-12T07:49:20Z","updated_at":"2015-10-12T09:31:22Z","closed_at":null,"body":"```\r\nIn [2]: a = np.arange(3); a.dtype\r\nOut[2]: dtype('int64')\r\n\r\nIn [3]: np.copysign(a, -1).dtype\r\nOut[3]: dtype('float64')\r\n```\r\n\r\nAnd then trying to change the sign in-place (which is the original motivation)\r\n\r\n```\r\nIn [4]: np.copysign(a, -1, a)\r\n---------------------------------------------------------------------------\r\nTypeError                                 Traceback (most recent call last)\r\n<ipython-input-4-7aac9b2aea00> in <module>()\r\n----> 1 np.copysign(a, -1, a)\r\n\r\nTypeError: ufunc 'copysign' output (typecode 'd') could not be coerced to provided output parameter (typecode 'l') according to the casting rule ''same_kind''\r\n\r\nIn [5]: x = np.arange(3, dtype=float)\r\n\r\nIn [6]: np.copysign(x, -1, x)\r\nOut[6]: array([-0., -1., -2.])\r\n\r\nIn [7]: np.__version__\r\nOut[7]: '1.10.0'\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/147347536","html_url":"https://github.com/numpy/numpy/issues/6454#issuecomment-147347536","issue_url":"https://api.github.com/repos/numpy/numpy/issues/6454","id":147347536,"user":{"login":"seberg","id":61977,"avatar_url":"https://avatars.githubusercontent.com/u/61977?v=3","gravatar_id":"","url":"https://api.github.com/users/seberg","html_url":"https://github.com/seberg","followers_url":"https://api.github.com/users/seberg/followers","following_url":"https://api.github.com/users/seberg/following{/other_user}","gists_url":"https://api.github.com/users/seberg/gists{/gist_id}","starred_url":"https://api.github.com/users/seberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seberg/subscriptions","organizations_url":"https://api.github.com/users/seberg/orgs","repos_url":"https://api.github.com/users/seberg/repos","events_url":"https://api.github.com/users/seberg/events{/privacy}","received_events_url":"https://api.github.com/users/seberg/received_events","type":"User","site_admin":false},"created_at":"2015-10-12T09:31:22Z","updated_at":"2015-10-12T09:31:22Z","body":"The reason is that copysign is only implemented for floating types, so the way it does integer types is by upcasting. You could of course provide the \"unsafe\" casting which would work, but under the hood, it will still cast to float and back."}}