Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid auto creation of indexes in concat #8872
Avoid auto creation of indexes in concat #8872
Changes from 10 commits
22995e9
7142c9f
7fb075a
285c1de
cc24757
90a2592
beb665a
22f361d
55166fc
322b76e
da6692b
35dfb67
fd3de2b
0a60172
21afbb1
6e9ead6
2534712
3e848eb
95d453c
ba5627e
3719ba7
018e74b
f680505
f10509a
8152c0a
aa813cf
e78de7d
b1329cc
a9f7e0c
2ce3dec
87a08b4
e0c6db1
214ed7d
78d2798
fc206b0
ce797f1
62e750f
f86c82f
4dd8d3c
d5d90fd
e00dbab
5bb88b8
1d471b1
766605d
971287f
10c0ed5
51eea5d
bde9f2b
d5241ce
7e8f895
ed85446
39571ba
206985b
86998e4
5894724
dad9433
b235c09
36a2223
e17c13f
e8fa857
648d5bc
deb292c
6dd57a9
b0e3612
b2f06a0
ff70fc7
2f97a5c
6d825e5
b88b5a6
30c7408
b243150
9e9e168
dca2fb9
c979672
ac27ce0
d73ac48
9ebbb33
d1b656d
ac998e9
0849b94
25764ca
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing those lines doesn't break any existing test because the line above
result[dim] = index_vars[dim]
actually re-creates a default PandasIndex when assigning the newdim
variable. However, this unnecessarily re-creates a new index (or re-wrap an existing one) and this may not work in the future if we allow passing a custom xarray index asdim
argument toconcat
.It would be better to explicitly add both
index
andindex_vars
toresult
. Best way would be to assign them toresult_indexes
andcoord_vars
respectively before constructing theCoordinates
object and then theresult
object, unless there are cases whereresult.drop_vars(unlabeled_dims)
would delete the index coordinate.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @benbovy. I think your comment might explain the behaviour I just noticed in zarr-developers/VirtualiZarr#18 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've addressed your comment now @benbovy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder to myself: The reason this test didn't catch the problem described in zarr-developers/VirtualiZarr#18 (comment) is because this test checks that concatenating datasets that start without indexes stay without indexes, whereas that problem is from concatenating datasets with indexes but having the coordinate variables be silently replaced by
IndexVariable
objects created from the index data.Check failure on line 1105 in xarray/tests/test_concat.py
GitHub Actions / ubuntu-latest py3.9 bare-minimum
Check failure on line 1105 in xarray/tests/test_concat.py
GitHub Actions / ubuntu-latest py3.9
Check failure on line 1105 in xarray/tests/test_concat.py
GitHub Actions / ubuntu-latest py3.11
Check failure on line 1105 in xarray/tests/test_concat.py
GitHub Actions / ubuntu-latest py3.9 min-all-deps
Check failure on line 1105 in xarray/tests/test_concat.py
GitHub Actions / ubuntu-latest py3.10 all-but-dask
Check failure on line 1105 in xarray/tests/test_concat.py
GitHub Actions / ubuntu-latest py3.12
Check failure on line 1105 in xarray/tests/test_concat.py
GitHub Actions / ubuntu-latest py3.10 flaky
Check failure on line 1105 in xarray/tests/test_concat.py
GitHub Actions / macos-latest py3.9
Check failure on line 1105 in xarray/tests/test_concat.py
GitHub Actions / macos-latest py3.12
Check failure on line 1105 in xarray/tests/test_concat.py
GitHub Actions / macos-latest py3.11