Skip to content

Commit 55b33cd

Browse files
rdrussottodcherian
authored andcommitted
Clarify apply_ufunc error message (Issue #2078) (#3119)
* 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
1 parent 76d4a67 commit 55b33cd

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

doc/whats-new.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ Enhancements
8080
Bug fixes
8181
~~~~~~~~~
8282

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

112115
Documentation

xarray/core/computation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,10 @@ def broadcast_compat_data(variable, broadcast_dims, core_dims):
502502
missing_core_dims = [d for d in core_dims if d not in set_old_dims]
503503
if missing_core_dims:
504504
raise ValueError(
505-
"operand to apply_ufunc has required core dimensions %r, but "
506-
"some of these are missing on the input variable: %r"
507-
% (list(core_dims), missing_core_dims)
505+
"operand to apply_ufunc has required core dimensions {}, but "
506+
"some of these dimensions are absent on an input variable: {}".format(
507+
list(core_dims), missing_core_dims
508+
)
508509
)
509510

510511
set_new_dims = set(new_dims)

0 commit comments

Comments
 (0)