Skip to content

Commit

Permalink
add support for drop_dims (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 authored Jan 29, 2021
1 parent 1a15e73 commit aa93aba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions cf_xarray/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def _get_with_standard_name(
_DEFAULT_KEY_MAPPERS: Mapping[str, Tuple[Mapper, ...]] = {
"dim": (_get_axis_coord,),
"dims": (_get_axis_coord,), # transpose
"drop_dims": (_get_axis_coord,), # drop_dims
"dimensions": (_get_axis_coord,), # stack
"dims_dict": (_get_axis_coord,), # swap_dims, rename_dims
"shifts": (_get_axis_coord,), # shift, roll
Expand Down
8 changes: 8 additions & 0 deletions cf_xarray/tests/test_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,3 +708,11 @@ def test_drop_sel_and_reset_coords(obj):
assert_identical(
obj.reset_coords("air"), obj.cf.reset_coords("air_temperature")
)


@pytest.mark.parametrize("ds", datasets)
def test_drop_dims(ds):

# Axis and coordinate
for cf_name in ["X", "longitude"]:
assert_identical(ds.drop_dims("lon"), ds.cf.drop_dims(cf_name))
2 changes: 1 addition & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ What's New
v0.4.1 (unreleased)
===================

- Support for ``.drop()``, ``.drop_vars()``, ``.drop_sel()``, ``.set_coords()``, ``.reset_coords()``. By `Mattia Almansi`_.
- Support for ``.drop()``, ``.drop_vars()``, ``.drop_sel()``, ``.drop_dims()``, ``.set_coords()``, ``.reset_coords()``. By `Mattia Almansi`_.
- Support for using ``standard_name`` in more functions. (:pr:`128`) By `Deepak Cherian`_
- Allow ``DataArray.cf[]`` with standard names. By `Deepak Cherian`_
- Rewrite the ``values`` of ``.cf.coords`` and ``.cf.data_vars`` with objects returned
Expand Down

0 comments on commit aa93aba

Please sign in to comment.