diff options
author | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2016-11-18 13:55:45 -0500 |
---|---|---|
committer | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2016-11-19 12:50:28 -0500 |
commit | 3f3d205cd3f607caeada0dddf41e996e288a3c50 (patch) | |
tree | d2e8cf7b53e0835edcdff4ee63fbbd7dc7a9665c /numpy/lib/function_base.py | |
parent | ec02bdc782f1de83520dfd2c4eb0c48d69c909e6 (diff) | |
download | numpy-3f3d205cd3f607caeada0dddf41e996e288a3c50.tar.gz |
MAINT: let average preserve subclass information.
This behaviour matches that for most other numpy functions (such as
np.mean). It was initially slated for 1.12, but replaced by a
FutureWarning. Hence, this is for 1.13.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index df9c7f177..352512513 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1092,19 +1092,7 @@ def average(a, axis=None, weights=None, returned=False): TypeError: Axis must be specified when shapes of a and weights differ. """ - # 3/19/2016 1.12.0: - # replace the next few lines with "a = np.asanyarray(a)" - if (type(a) not in (np.ndarray, np.matrix) and - issubclass(type(a), np.ndarray)): - warnings.warn("np.average currently does not preserve subclasses, but " - "will do so in the future to match the behavior of most " - "other numpy functions such as np.mean. In particular, " - "this means calls which returned a scalar may return a " - "0-d subclass object instead.", - FutureWarning, stacklevel=2) - - if not isinstance(a, np.matrix): - a = np.asarray(a) + a = np.asanyarray(a) if weights is None: avg = a.mean(axis) |