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/3126#issuecomment-512058648,https://api.github.com/repos/pydata/xarray/issues/3126,512058648,MDEyOklzc3VlQ29tbWVudDUxMjA1ODY0OA==,5635139,2019-07-17T00:56:58Z,2019-07-17T00:56:58Z,MEMBER,Do you have an accidental binary file in the commit? https://github.com/pydata/xarray/pull/3126/files#diff-337006a573a2971594e829114137f91b,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,467856527 https://github.com/pydata/xarray/pull/3126#issuecomment-512031393,https://api.github.com/repos/pydata/xarray/issues/3126,512031393,MDEyOklzc3VlQ29tbWVudDUxMjAzMTM5Mw==,2818208,2019-07-16T22:50:04Z,2019-07-16T22:50:04Z,CONTRIBUTOR,"Okay, a couple changes to the original PR: we now perform a shallow copy of the returned index in `DataWithCoords.get_index` and `Indexes.__getitem__`. The latter is needed because both `Dataset.indexes` and `DataArray.indexes` returns an `Indexes` object. Finally, I added [a bunch of tests for various index accessors](https://github.com/pydata/xarray/pull/3126/files#diff-02d824ae7c673c0c4bf2f30dff024753R3055). This seems pretty robust: ```python >>> import pandas as pd >>> import xarray as xr >>> index = pd.Index(list('abcd'), name='foo') >>> series = pd.Series(range(4), index) >>> array = xr.DataArray.from_series(series) >>> array.get_index('foo').name = 'bar' >>> array.get_index('foo').name 'foo' >>> array['foo'].to_index().name = 'bar' >>> array['foo'].to_index().name 'foo' >>> array.to_index().name = 'bar' >>> array.to_index().name 'foo' >>> array.indexes['foo'].name = 'bar' >>> array.indexes['foo'].name 'foo' ``` Since a `Dataset` is just a collection of `DataArray` objects, the behavior propagates nicely, e.g. ```python >>> dataset = xr.Dataset({'myvar': array}) >>> dataset['myvar'].to_index().name = 'bar' >>> dataset['myvar'].to_index().name 'foo' >>> dataset.indexes['foo'].name = 'bar' >>> dataset.indexes['foo'].name 'foo' ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,467856527 https://github.com/pydata/xarray/pull/3126#issuecomment-512027994,https://api.github.com/repos/pydata/xarray/issues/3126,512027994,MDEyOklzc3VlQ29tbWVudDUxMjAyNzk5NA==,5635139,2019-07-16T22:36:51Z,2019-07-16T22:36:51Z,MEMBER,"> Do we want all views of indexes to be immutable or do we trust the user to not do stuff like this: Is there a reasonable way of making that immutable? Given that the index allows its name to be mutated, I'm not sure. (we can also separate that issue from this change, which is already 👍 )","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,467856527 https://github.com/pydata/xarray/pull/3126#issuecomment-511214715,https://api.github.com/repos/pydata/xarray/issues/3126,511214715,MDEyOklzc3VlQ29tbWVudDUxMTIxNDcxNQ==,24736507,2019-07-14T16:02:51Z,2019-07-16T22:33:30Z,NONE,"Hello @gwgundersen! 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 2019-07-16 22:33:30 UTC","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,467856527 https://github.com/pydata/xarray/pull/3126#issuecomment-511216252,https://api.github.com/repos/pydata/xarray/issues/3126,511216252,MDEyOklzc3VlQ29tbWVudDUxMTIxNjI1Mg==,22429695,2019-07-14T16:23:30Z,2019-07-16T22:33:26Z,NONE,"# [Codecov](https://codecov.io/gh/pydata/xarray/pull/3126?src=pr&el=h1) Report > Merging [#3126](https://codecov.io/gh/pydata/xarray/pull/3126?src=pr&el=desc) into [master](https://codecov.io/gh/pydata/xarray/commit/8da3f67ea583e0588291162067229b2f3ce2993e?src=pr&el=desc) will **decrease** coverage by `0.91%`. > The diff coverage is `100%`. ```diff @@ Coverage Diff @@ ## master #3126 +/- ## ========================================== - Coverage 95.99% 95.08% -0.92% ========================================== Files 63 63 Lines 12799 12801 +2 ========================================== - Hits 12287 12172 -115 - Misses 512 629 +117 ``` ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,467856527 https://github.com/pydata/xarray/pull/3126#issuecomment-511716413,https://api.github.com/repos/pydata/xarray/issues/3126,511716413,MDEyOklzc3VlQ29tbWVudDUxMTcxNjQxMw==,2818208,2019-07-16T08:20:34Z,2019-07-16T08:21:07Z,CONTRIBUTOR,"Locally, I've moved my changes from `DataArray.to_series` to `DataWithCoords.get_index`, and my tests still pass. After work, I'll write some more tests, e.g. for for `DataArray.to_index`, and push. @shoyer, it seems like this issue happens anywhere the user can modify a Pandas index. For example, the Dataset bug in [my comment yesterday](https://github.com/pydata/xarray/pull/3126#issuecomment-511506569). Do we want all views of indexes to be immutable or do we trust the user to not do stuff like this: ```python >>> dataset.indexes['mutable?'].name = 'yes' >>> dataset.indexes['mutable?'].name 'yes' ```","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,467856527 https://github.com/pydata/xarray/pull/3126#issuecomment-511523854,https://api.github.com/repos/pydata/xarray/issues/3126,511523854,MDEyOklzc3VlQ29tbWVudDUxMTUyMzg1NA==,5635139,2019-07-15T18:48:26Z,2019-07-15T18:48:26Z,MEMBER,"> It looks like to_series calls to_index, which calls get_index, Thanks for finding that. That sounds right - if we make these changes there then I think we've solved the problem at its root and we should fix all these cases? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,467856527 https://github.com/pydata/xarray/pull/3126#issuecomment-511506569,https://api.github.com/repos/pydata/xarray/issues/3126,511506569,MDEyOklzc3VlQ29tbWVudDUxMTUwNjU2OQ==,2818208,2019-07-15T17:59:23Z,2019-07-15T17:59:23Z,CONTRIBUTOR,"@max-sixty, `name` is just a mutable property on a Pandas index: ```python >>> dates = pd.date_range('01-Jan-2019', '31-Jan-2019', name='mutable?') >>> series = pd.Series(np.random.randn(dates.size), dates) >>> series.index.name 'mutable?' >>> series.index.name = 'yes' >>> series.index.name 'yes' ``` But you're right that `to_series` is the wrong place. It looks like `to_series` calls `to_index`, which calls [`get_index`](https://github.com/pydata/xarray/blob/master/xarray/core/common.py#L288), which is inherited by other classes such as `Dataset`. For example, the bug persists with `Dataset` despite my fix: ```python >>> dates = pd.date_range('01-Jan-2019', '31-Jan-2019', name='mutable?') >>> series = pd.Series(np.random.randn(dates.size), dates) >>> dataset = xr.Dataset({'foo': series}) >>> dataset.indexes['mutable?'].name = 'yes' >>> dataset.indexes['mutable?'].name 'yes' ``` Does anyone know if `get_index` is the best place for this? Maybe the tests should be somewhere more generic as well.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,467856527 https://github.com/pydata/xarray/pull/3126#issuecomment-511451574,https://api.github.com/repos/pydata/xarray/issues/3126,511451574,MDEyOklzc3VlQ29tbWVudDUxMTQ1MTU3NA==,5635139,2019-07-15T15:32:09Z,2019-07-15T15:32:09Z,MEMBER,"I don't quite understand why the previous constructor was returning a mutable view, but the tests look great. @gwgundersen do you know if we should instead be changing the `to_index` method which the `to_series` calls? Any other comments from anyone?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,467856527