Skip to content

Check for just ... in stack etc, and raise with a useful error message #6051

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

Closed
dcherian opened this issue Dec 6, 2021 · 4 comments · Fixed by #6132
Closed

Check for just ... in stack etc, and raise with a useful error message #6051

dcherian opened this issue Dec 6, 2021 · 4 comments · Fixed by #6132

Comments

@dcherian
Copy link
Contributor

dcherian commented Dec 6, 2021

Is your feature request related to a problem? Please describe.

The following doesn't work

import xarray as xr

da = xr.DataArray([[1,2],[1,2]], dims=("x", "y"))
da.stack(flat=...)

Describe the solution you'd like
This could be equivalent to

da.stack(flat=da.dims)

I think using ds.dims it should be fine for datasets too.

@max-sixty
Copy link
Collaborator

It still needs to be in a list! Otherwise it would be funky to do flat=[x, ...]

In [2]: import xarray as xr
   ...:
   ...: da = xr.DataArray([[1,2],[1,2]], dims=("x", "y"))
   ...: da.stack(flat=[...])

@dcherian
Copy link
Contributor Author

dcherian commented Dec 6, 2021

Can we special-case ... and convert it to [...]?

@max-sixty
Copy link
Collaborator

I see @mathause agrees, so I am v happy to be voted into the minority, but I would vote against it — ... stands for x, y, not [x, y], and we're better to hold that line rather than have ... be a "mood of 'etc'".

I would def be up for updating the error message to check for this mistake.

(I worry that when people disagree we can stay with the status quo, so I really would be fine doing this if you think it's better. Also I didn't get the release done yesterday so I should be downweighted 😁 )

@dcherian
Copy link
Contributor Author

dcherian commented Dec 7, 2021

— ... stands for x, y, not [x, y], and we're better to hold that line rather than have ... be a "mood of 'etc'".

Sounds good to me. "mood of 'etc'". is a great phrase!

I also agree with checking for ... and raising an error asking the user to enter [...]

@max-sixty max-sixty changed the title Support Ellipsis in stack Check for just ... in stack etc, and raise with a useful error message Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants