File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,9 @@ Enhancements
57
57
Bug fixes
58
58
~~~~~~~~~
59
59
60
+ - Raise an informative error message when using ``apply_ufunc `` with numpy
61
+ v1.11 (:issue: `1956 `).
62
+ By `Stephan Hoyer <https://github.com/shoyer >`_.
60
63
- Fix the precision drop after indexing datetime64 arrays (:issue: `1932 `).
61
64
By `Keisuke Fujii <https://github.com/fujiisoup >`_.
62
65
- Fix kwarg `colors ` clashing with auto-inferred `cmap ` (:issue: `1461 `)
Original file line number Diff line number Diff line change 1
1
"""
2
2
Functions for applying functions that act on arrays to xarray's labeled data.
3
-
4
- NOT PUBLIC API.
5
3
"""
4
+ from __future__ import absolute_import , division , print_function
5
+ from distutils .version import LooseVersion
6
6
import functools
7
7
import itertools
8
8
import operator
@@ -882,10 +882,21 @@ def earth_mover_distance(first_samples,
882
882
func = functools .partial (func , ** kwargs_ )
883
883
884
884
if vectorize :
885
- func = np .vectorize (func ,
886
- otypes = output_dtypes ,
887
- signature = signature .to_gufunc_string (),
888
- excluded = set (kwargs ))
885
+ if signature .all_core_dims :
886
+ # we need the signature argument
887
+ if LooseVersion (np .__version__ ) < '1.12' : # pragma: no cover
888
+ raise NotImplementedError (
889
+ 'numpy 1.12 or newer required when using vectorize=True '
890
+ 'in xarray.apply_ufunc with non-scalar output core '
891
+ 'dimensions.' )
892
+ func = np .vectorize (func ,
893
+ otypes = output_dtypes ,
894
+ signature = signature .to_gufunc_string (),
895
+ excluded = set (kwargs ))
896
+ else :
897
+ func = np .vectorize (func ,
898
+ otypes = output_dtypes ,
899
+ excluded = set (kwargs ))
889
900
890
901
variables_ufunc = functools .partial (apply_variable_ufunc , func ,
891
902
signature = signature ,
You can’t perform that action at this time.
0 commit comments