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/7152#issuecomment-1292363055,https://api.github.com/repos/pydata/xarray/issues/7152,1292363055,IC_kwDOAMm_X85NB-Uv,73678798,2022-10-26T17:19:20Z,2022-10-26T17:19:20Z,CONTRIBUTOR,"Thanks @Illviljan, @dcherian, and @keewis so much for the help.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1292355722,https://api.github.com/repos/pydata/xarray/issues/7152,1292355722,IC_kwDOAMm_X85NB8iK,14371165,2022-10-26T17:14:12Z,2022-10-26T17:14:12Z,MEMBER,"@patrick-naylor, feel free to try out a better default example if you want.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1287899447,https://api.github.com/repos/pydata/xarray/issues/7152,1287899447,IC_kwDOAMm_X85Mw8k3,14808389,2022-10-22T19:59:16Z,2022-10-22T19:59:48Z,MEMBER,"well, that's just it: there's no way to discriminate between docstrings and multi-line triple-quoted strings without parsing the python code (which is definitely out of scope), so `blackdoc` doesn't even attempt to. Instead, any line that begins with `>>> ` will be assumed to be doctest lines. So with that, the numbers mean: line 201, character 27. When created that file we decided to skip the `generate_*` file, but because the file was renamed that rule does not work anymore. Could you update the `pre-commit` configuration?","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1287850448,https://api.github.com/repos/pydata/xarray/issues/7152,1287850448,IC_kwDOAMm_X85MwwnQ,14371165,2022-10-22T16:40:12Z,2022-10-22T16:40:12Z,MEMBER,"@keewis What does the numbers mean in `Cannot parse: 201:27`? Because I can't find any functions with docstrings in this file, it's just a bunch of multiline strings that are defined to variables and in my mind shouldn't trigger blackdoc.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1287825909,https://api.github.com/repos/pydata/xarray/issues/7152,1287825909,IC_kwDOAMm_X85Mwqn1,14808389,2022-10-22T15:21:44Z,2022-10-22T15:24:45Z,MEMBER,"> do you understand this blackdoc error? so the reason is the position of the triple quotes: with ```python def f(): """""" >>> 1 + 2"""""" pass ``` the extracted line will become: `1 + 2""""""`, which when handed to `black` results in that error. Technically, that's a bug (the triple quotes mark the end of the docstring), but one that is a bit tricky to fix: `blackdoc` is implemented using a line parser, which does not work too well if the transition happen somewhere within the line. My guess is that it would have to start counting quotes which I've tried to avoid up until now since there's a lot of details to get right (see also keewis/blackdoc#145) Edit: for now, I guess it would be fine to add something like `The closing quotes are not on their own line.` to the error message","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1287768499,https://api.github.com/repos/pydata/xarray/issues/7152,1287768499,IC_kwDOAMm_X85Mwcmz,14371165,2022-10-22T11:38:03Z,2022-10-22T11:38:03Z,MEMBER,"@dcherian cumsum for resample fails for some reason do you have any ideas? ```python import numpy as np import pandas as pd import xarray as xr da = xr.DataArray( np.array([1, 2, 3, 1, 2, np.nan]), dims=""time"", coords=dict( time=(""time"", pd.date_range(""01-01-2001"", freq=""M"", periods=6)), labels=(""time"", np.array([""a"", ""b"", ""c"", ""c"", ""b"", ""a""])), ), ) ds = xr.Dataset(dict(da=da)) a = ds.resample(time=""3M"") a.cumsum() Traceback (most recent call last): File ""C:\Users\J.W\anaconda3\envs\xarray-tests\lib\site-packages\spyder_kernels\py3compat.py"", line 356, in compat_exec exec(code, globals, locals) File ""c:\users\j.w\documents\github\xarray\xarray\util\untitled2.py"", line 20, in a.cumsum() File ""C:\Users\J.W\Documents\GitHub\xarray\xarray\core\_aggregations.py"", line 4921, in cumsum return self.reduce( File ""C:\Users\J.W\Documents\GitHub\xarray\xarray\core\resample.py"", line 395, in reduce return super().reduce( File ""C:\Users\J.W\Documents\GitHub\xarray\xarray\core\groupby.py"", line 1357, in reduce return self.map(reduce_dataset) File ""C:\Users\J.W\Documents\GitHub\xarray\xarray\core\resample.py"", line 342, in map return combined.rename({self._resample_dim: self._dim}) File ""C:\Users\J.W\Documents\GitHub\xarray\xarray\core\dataset.py"", line 3646, in rename return self._rename(name_dict=name_dict, **names) File ""C:\Users\J.W\Documents\GitHub\xarray\xarray\core\dataset.py"", line 3587, in _rename raise ValueError( ValueError: cannot rename '__resample_dim__' because it is not a variable or dimension in this dataset ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1287768091,https://api.github.com/repos/pydata/xarray/issues/7152,1287768091,IC_kwDOAMm_X85Mwcgb,14371165,2022-10-22T11:35:14Z,2022-10-22T11:35:14Z,MEMBER,"@keewis do you understand this blackdoc error? ``` trim trailing whitespace.................................................Passed fix end of files.........................................................Passed check yaml...............................................................Passed debug statements (python)................................................Passed mixed line ending........................................................Passed autoflake................................................................Passed isort....................................................................Passed pyupgrade................................................................Passed black....................................................................Passed black-jupyter............................................................Passed blackdoc.................................................................Failed - hook id: blackdoc - exit code: 123 error: cannot format /code/xarray/util/generate_aggregations.py: Cannot parse: 201:27: EOF in multi-line string Oh no! 💥 💔 💥 215 files left unchanged, 1 file fails to reformat. ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1287253517,https://api.github.com/repos/pydata/xarray/issues/7152,1287253517,IC_kwDOAMm_X85Mue4N,2448579,2022-10-21T17:35:03Z,2022-10-21T17:35:03Z,MEMBER,"> o you think it would be better to finish this PR as the creation of _aggregations.py to give the cum methods better documentation? Then start a new one to fix https://github.com/pydata/xarray/issues/6528? Sure that would be a good intermediate step. Let us know if you need help.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1287246401,https://api.github.com/repos/pydata/xarray/issues/7152,1287246401,IC_kwDOAMm_X85MudJB,73678798,2022-10-21T17:28:12Z,2022-10-21T17:28:12Z,CONTRIBUTOR,@dcherian Do you think it would be better to finish this PR as the creation of _aggregations.py to give the cum methods better documentation? Then start a new one to fix #6528?,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1287138940,https://api.github.com/repos/pydata/xarray/issues/7152,1287138940,IC_kwDOAMm_X85MuC58,2448579,2022-10-21T15:42:12Z,2022-10-21T15:42:12Z,MEMBER,"Thanks for taking this on @patrick-naylor ! This is a decent-sized project! > Using apply_ufunc and np.cumsum/cumprod has some issues as it only finds the cumulative across one axis which makes iterating through each dimension necessary. `np.cumsum` only supports an integer axis so this is OK? `flox` doesn't support `cumsum` at the moment (https://github.com/xarray-contrib/flox/issues/91) so we can delete that bit and just have one code path.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1286660760,https://api.github.com/repos/pydata/xarray/issues/7152,1286660760,IC_kwDOAMm_X85MsOKY,14371165,2022-10-21T08:51:12Z,2022-10-21T08:51:12Z,MEMBER,"I don't think you have `flox` installed, if it's not installed the code will take the old path. Do `conda install flox` and I think you'll get the NotImplementedError. Then you maybe have to change the default settings in cumsum so flox is not used.","{""total_count"": 1, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 1, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1284713697,https://api.github.com/repos/pydata/xarray/issues/7152,1284713697,IC_kwDOAMm_X85Mkyzh,73678798,2022-10-19T23:52:47Z,2022-10-19T23:52:47Z,CONTRIBUTOR,"I've merged the cumulative and reduction files into generate_aggregations.py and _aggregations.py. This uses the original version of reductions with an additional statement on the dataset methods that adds the original coordinates back in. Using apply_ufunc and np.cumsum/cumprod has some issues as it only finds the cumulative across one axis which makes iterating through each dimension necessary. This makes it slower than the original functions and also causes some problems with the groupby method. Happy for any input on how the method using apply_ufunc might be usable or on any ways to change the current method. I'm getting a few issues I don't quite understand: - When running pytest on my local repository I get no errors but it's failing the checks here with a NotImplementedError - Black is having an issue with some of the strings in generate_aggregations. It's saying it cannot parse what should be valid code. Thanks! ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1279303479,https://api.github.com/repos/pydata/xarray/issues/7152,1279303479,IC_kwDOAMm_X85MQJ83,43316012,2022-10-14T17:57:09Z,2022-10-14T17:57:09Z,COLLABORATOR,"> I'm running into an issue with variables without the core dimensions. Would it be better to do a work around in cumsum or in apply_unfunc like you mentioned in #6391 While this is definitely worth an improvement, it is quite out of scope for this PR. Can you define Datasets such that this problem does not occur? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1275334035,https://api.github.com/repos/pydata/xarray/issues/7152,1275334035,IC_kwDOAMm_X85MBA2T,73678798,2022-10-11T22:12:13Z,2022-10-11T22:12:13Z,CONTRIBUTOR," > ```python > def cumsum(..., dim): > return xr.apply_ufunc( > np.cumsum if skipna else np.nancumsum, > obj, > input_core_dims=[dim], > output_core_dims=[dim], > kwargs={""axis"": -1}, > ) > # now transpose dimensions back to input order > ``` I'm running into an issue with variables without the core dimensions. Would it be better to do a work around in cumsum or in apply_unfunc like you mentioned in #6391 ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1275131950,https://api.github.com/repos/pydata/xarray/issues/7152,1275131950,IC_kwDOAMm_X85MAPgu,2448579,2022-10-11T18:51:26Z,2022-10-11T18:51:26Z,MEMBER,"> Is there a particular reason why there is no cumprod for GroupBy objects? Nope. Just wasn't added in :)","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1275123446,https://api.github.com/repos/pydata/xarray/issues/7152,1275123446,IC_kwDOAMm_X85MANb2,73678798,2022-10-11T18:43:59Z,2022-10-11T18:43:59Z,CONTRIBUTOR,"Thanks @dcherian, I'll try to work that in. Is there a particular reason why there is no cumprod for GroupBy objects?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1274963421,https://api.github.com/repos/pydata/xarray/issues/7152,1274963421,IC_kwDOAMm_X85L_mXd,2448579,2022-10-11T16:27:15Z,2022-10-11T16:30:32Z,MEMBER,"Thanks @patrick-naylor ! Instead of using `Dataset.reduce` I think we want something like ``` python def cumsum(..., dim): return xr.apply_ufunc( np.cumsum if skipna else np.nancumsum, obj, input_core_dims=[dim], output_core_dims=[dim], kwargs={""axis"": -1}, ) # now transpose dimensions back to input order ``` to fix #6528. At the moment, this should also work on GroupBy objects quite nicely.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1273835619,https://api.github.com/repos/pydata/xarray/issues/7152,1273835619,IC_kwDOAMm_X85L7TBj,73678798,2022-10-10T21:27:46Z,2022-10-10T21:27:46Z,CONTRIBUTOR,Great I'll start working on that. Shouldn't take too long,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1273832790,https://api.github.com/repos/pydata/xarray/issues/7152,1273832790,IC_kwDOAMm_X85L7SVW,14371165,2022-10-10T21:23:17Z,2022-10-10T21:23:17Z,MEMBER,"Right now, I think `cumsum` and `cumprod` is enough. [numpy-groupies](https://github.com/ml31415/numpy-groupies) has a few more examples that I suppose we could support in the future.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1273829157,https://api.github.com/repos/pydata/xarray/issues/7152,1273829157,IC_kwDOAMm_X85L7Rcl,73678798,2022-10-10T21:17:23Z,2022-10-10T21:17:23Z,CONTRIBUTOR,@Illviljan That is definitely something I could do. Are there any other methods I should be including in this? ,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394 https://github.com/pydata/xarray/pull/7152#issuecomment-1273827112,https://api.github.com/repos/pydata/xarray/issues/7152,1273827112,IC_kwDOAMm_X85L7Q8o,14371165,2022-10-10T21:14:28Z,2022-10-10T21:14:28Z,MEMBER,"Very nice, this is something that's been on the TODO list! :) I believe we wanted to rename `generate_reductions.py` to `generate_aggregations.py` so cumsum et al could be included and generated there as well. Is there a lot of work for you if try to merge these into that one?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1403614394