Skip to content

Commit

Permalink
Clarify apply_ufunc error message (Issue #2078) (#3119)
Browse files Browse the repository at this point in the history
* Clarify error message (#2078)

* Update whats-new

* Add issue number to whats-new

* Update xarray/core/computation.py

Co-Authored-By: Deepak Cherian <[email protected]>

* black computation.py for formatting conventions
  • Loading branch information
rdrussotto authored and dcherian committed Aug 23, 2019
1 parent 76d4a67 commit 55b33cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ Enhancements
Bug fixes
~~~~~~~~~

- Improve "missing dimensions" error message for :py:func:`~xarray.apply_ufunc`
(:issue:`2078`).
By `Rick Russotto <https://github.com/rdrussotto>`_.
- :py:meth:`~xarray.DataArray.assign_coords` now supports dictionary arguments
(:issue:`3231`).
By `Gregory Gundersen <https://github.com/gwgundersen>`_.
Expand All @@ -106,7 +109,7 @@ Bug fixes
- Fix error that arises when using open_mfdataset on a series of netcdf files
having differing values for a variable attribute of type list. (:issue:`3034`)
By `Hasan Ahmad <https://github.com/HasanAhmadQ7>`_.

.. _whats-new.0.12.3:

Documentation
Expand Down
7 changes: 4 additions & 3 deletions xarray/core/computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,10 @@ def broadcast_compat_data(variable, broadcast_dims, core_dims):
missing_core_dims = [d for d in core_dims if d not in set_old_dims]
if missing_core_dims:
raise ValueError(
"operand to apply_ufunc has required core dimensions %r, but "
"some of these are missing on the input variable: %r"
% (list(core_dims), missing_core_dims)
"operand to apply_ufunc has required core dimensions {}, but "
"some of these dimensions are absent on an input variable: {}".format(
list(core_dims), missing_core_dims
)
)

set_new_dims = set(new_dims)
Expand Down

0 comments on commit 55b33cd

Please sign in to comment.