html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/pull/2533#issuecomment-851783635,https://api.github.com/repos/pydata/xarray/issues/2533,851783635,MDEyOklzc3VlQ29tbWVudDg1MTc4MzYzNQ==,5635139,2021-06-01T03:47:01Z,2021-06-01T03:47:01Z,MEMBER,"Nice, that seems to work! Is anyone else more familiar with whether using `context` in this way is reasonable?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,376167325 https://github.com/pydata/xarray/pull/2533#issuecomment-851688260,https://api.github.com/repos/pydata/xarray/issues/2533,851688260,MDEyOklzc3VlQ29tbWVudDg1MTY4ODI2MA==,31115101,2021-05-31T21:22:01Z,2021-05-31T21:22:01Z,CONTRIBUTOR,"> context I can only find references regarding `ufunc`s in the numpy docs when I look up the context. I would think that in that case the shapes should be fine, but please do correct me if not? `_unary_op` calls `__array_wrap__(context=None)`; if the function only checks the shape when `context is None` and a dummy value gets passed in for the context, that's one way to avoid it.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,376167325 https://github.com/pydata/xarray/pull/2533#issuecomment-434854143,https://api.github.com/repos/pydata/xarray/issues/2533,434854143,MDEyOklzc3VlQ29tbWVudDQzNDg1NDE0Mw==,24736507,2018-10-31T21:28:14Z,2021-05-31T21:16:46Z,NONE,"Hello @lilyminium! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: ##### Comment last updated at 2021-05-31 21:16:46 UTC","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,376167325 https://github.com/pydata/xarray/pull/2533#issuecomment-851631521,https://api.github.com/repos/pydata/xarray/issues/2533,851631521,MDEyOklzc3VlQ29tbWVudDg1MTYzMTUyMQ==,5635139,2021-05-31T18:38:43Z,2021-05-31T18:38:43Z,MEMBER,"> Hmmmm. It's been quite some time since I've last used xarray, but I'm not sure I see an easy way to: > > 1. hijack np.insert (which I would guess goes directly to `DataArray.__array_wrap__ / __array_finalize__`) > > 2. without passing a `fastpath`-like argument to `__array_wrap__`, but > > 3. efficiently not checking the shape of safe operations, like `_unary_op`. I think that's exactly correct. Without being able to tell `__array_wrap__` from `_unary_op` that we don't need to check the sizes, they all follow the same path. Is it possible to use the `context` arg for this? I don't think it's sufficiently flexible from an initial glance of the docs. Maybe this new implementation has a low enough overhead that it's worthwhile? If we do go ahead — what about calling `_check_shape_consistency` from within `__array_wrap__` after creating the object, instead of adding the `fastpath` kwarg? ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,376167325 https://github.com/pydata/xarray/pull/2533#issuecomment-851614917,https://api.github.com/repos/pydata/xarray/issues/2533,851614917,MDEyOklzc3VlQ29tbWVudDg1MTYxNDkxNw==,31115101,2021-05-31T17:46:49Z,2021-05-31T17:46:49Z,CONTRIBUTOR,The 3.7 test looks like an installation error.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,376167325 https://github.com/pydata/xarray/pull/2533#issuecomment-851599339,https://api.github.com/repos/pydata/xarray/issues/2533,851599339,MDEyOklzc3VlQ29tbWVudDg1MTU5OTMzOQ==,31115101,2021-05-31T17:01:25Z,2021-05-31T17:01:25Z,CONTRIBUTOR,"Hmmmm. It's been quite some time since I've last used xarray, but I'm not sure I see an easy way to: 1. hijack np.insert (which I would guess goes directly to `DataArray.__array_wrap__ / __array_finalize__`) 2. without passing a `fastpath`-like argument to `__array_wrap__`, but 3. efficiently not checking the shape of safe operations, like `_unary_op`. I have for now stuck `fastpath` in `_replace` but it fails condition 3 and just runs for all calls to `__array_wrap__`.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,376167325 https://github.com/pydata/xarray/pull/2533#issuecomment-850606084,https://api.github.com/repos/pydata/xarray/issues/2533,850606084,MDEyOklzc3VlQ29tbWVudDg1MDYwNjA4NA==,31115101,2021-05-28T18:55:14Z,2021-05-28T18:55:14Z,CONTRIBUTOR,"Ooh, this is a blast from the past. Anyone passing by, feel free to pick this up if you like, otherwise I'll see what I can do over the weekend :)","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,376167325 https://github.com/pydata/xarray/pull/2533#issuecomment-850580427,https://api.github.com/repos/pydata/xarray/issues/2533,850580427,MDEyOklzc3VlQ29tbWVudDg1MDU4MDQyNw==,5635139,2021-05-28T18:00:05Z,2021-05-28T18:00:05Z,MEMBER,"This would still be valuable if @lilyminium (or someone else, if they're not interested) would want to finish this off.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,376167325 https://github.com/pydata/xarray/pull/2533#issuecomment-436498217,https://api.github.com/repos/pydata/xarray/issues/2533,436498217,MDEyOklzc3VlQ29tbWVudDQzNjQ5ODIxNw==,1217238,2018-11-07T04:07:59Z,2018-11-07T04:07:59Z,MEMBER,"> Does adding fastpath to skip shape checking in array_wrap work? fastpath=True in both DataArray.array_wrap and Variable.array_wrap didn't seem to break any tests. I think it would be slightly better to stick with a separate method for xarray's fast-path. `__array_wrap__` is a special protocol used by NumPy, so there's always a (unlikely) risk that if we use different arguments in our version it could break in the future.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,376167325 https://github.com/pydata/xarray/pull/2533#issuecomment-436474639,https://api.github.com/repos/pydata/xarray/issues/2533,436474639,MDEyOklzc3VlQ29tbWVudDQzNjQ3NDYzOQ==,31115101,2018-11-07T01:50:06Z,2018-11-07T01:50:06Z,CONTRIBUTOR,"> I think the clean way to fix this would be to add error checking to `DataArray.__array_wrap__`. But we currently use this method inside `DataArray._unary_op` (and maybe elsewhere?), which is called every time you do unwary math with an xarray object (e.g., `- `). We’ll want to update these uses to use a method that uses the same shortcut to avoid redundant metadata checks. Does adding fastpath to skip shape checking in __array_wrap__ work? fastpath=True in both DataArray.__array_wrap__ and Variable.__array_wrap__ didn't seem to break any tests.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,376167325 https://github.com/pydata/xarray/pull/2533#issuecomment-435271342,https://api.github.com/repos/pydata/xarray/issues/2533,435271342,MDEyOklzc3VlQ29tbWVudDQzNTI3MTM0Mg==,1217238,2018-11-02T04:57:31Z,2018-11-02T04:57:31Z,MEMBER,"@lilyminium thanks for looking into this! I think the specific problem here is due to our use of the shortcut `_replace` method in `DataArray.__array_wrap__` (which is called by NumPy, e.g., inside np.insert): https://github.com/pydata/xarray/blob/6d55f99905d664ef73cb708cfe8c52c2c651e8dc/xarray/core/dataarray.py#L193 I think the clean way to fix this would be to add error checking to `DataArray.__array_wrap__`. But we currently use this method inside `DataArray._unary_op` (and maybe elsewhere?), which is called every time you do unwary math with an xarray object (e.g., `- `). We’ll want to update these uses to use a method that uses the same shortcut to avoid redundant metadata checks.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,376167325