Skip to content
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

Add missing_dims argument allowing isel() to ignore missing dimensions #3923

Merged
merged 7 commits into from
Apr 3, 2020

Conversation

johnomotani
Copy link
Contributor

@johnomotani johnomotani commented Mar 31, 2020

Note: only added to DataArray.isel() and Variable.isel(). A Dataset should include all dimensions, so presumably it should always be an error to pass a non-existent dimension when slicing a Dataset?

@max-sixty
Copy link
Collaborator

Thanks @johnomotani ; appreciate the PR.

I'm not strongly opposed to this. I haven't personally had an instance where I've wanted this keyword, but that's not overly representative of others' cases.
What do people think, @pydata/xarray ?

Separately, if we do merge, I think we should align with the keywords on drop_vars: raise / ignore

@dcherian
Copy link
Contributor

dcherian commented Apr 3, 2020

I don't see why Dataset.isel is different.

+1 for using the drop_vars kwarg

@johnomotani
Copy link
Contributor Author

The Linux-py38-upstream-dev test is failing in cftime tests at various places similar to this

        with create_tmp_file() as tmp_file:
            original.to_netcdf(tmp_file)
            with pytest.warns(None) as record:
                with open_dataset(tmp_file, use_cftime=False) as ds:
                    assert_identical(expected_x, ds.x)
                    assert_identical(expected_time, ds.time)
>               assert not record
E               assert not WarningsChecker(record=True)

Don't think it's related to this PR...

@keewis
Copy link
Collaborator

keewis commented Apr 3, 2020

you're right, that's #3928

@max-sixty
Copy link
Collaborator

Great, thanks a lot @johnomotani !

@max-sixty max-sixty merged commit 9b5140e into pydata:master Apr 3, 2020
dcherian added a commit to dcherian/xarray that referenced this pull request Apr 5, 2020
* master:
  Use divergent colormap if lowest and highest level span 0 (pydata#3913)
  Bugfix for plotting transposed 2d coords (pydata#3934)
  Allow plotting bool data (pydata#3766)
  facetgrid: fix case when vmin == vmax (pydata#3916)
  add a CI that tests xarray with all optional dependencies but dask (pydata#3919)
  Add missing_dims argument allowing isel() to ignore missing dimensions (pydata#3923)
  Only fail if a specific warning occurs (pydata#3930)
  Fix minor code quality issues (pydata#3626)
  Fix for stack+groupby+apply w/ non-increasing coord (pydata#3906)
  reactivate the macos CI (pydata#3920)
  add pint to the output of show_versions() (pydata#3918)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow isel to ignore missing dimensions?
4 participants