diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-03-08 11:07:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-08 11:07:06 +0000 |
commit | 485b099cd4b82d65dc38cb2b28c7119f003c76c4 (patch) | |
tree | 809cbc5926d6c38aa87e42f980a4e9b5568901c0 /numpy/lib/tests/test_function_base.py | |
parent | 6a3edf3210b439a4d1a51acb4e01bac017697ee6 (diff) | |
parent | 1588ae39ffb51ea916f03510671aab711fdfb568 (diff) | |
download | numpy-485b099cd4b82d65dc38cb2b28c7119f003c76c4.tar.gz |
Merge pull request #8750 from warut-vijit/master
BUG: Fix np.average for object arrays
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 4fb0dba51..188c1c2ea 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -3,6 +3,7 @@ from __future__ import division, absolute_import, print_function import operator import warnings import sys +import decimal import numpy as np from numpy.testing import ( @@ -341,6 +342,12 @@ class TestAverage(TestCase): w = np.array([[1,2],[3,4]], dtype=wt) assert_equal(np.average(a, weights=w).dtype, np.dtype(rt)) + def test_object_dtype(self): + a = np.array([decimal.Decimal(x) for x in range(10)]) + w = np.array([decimal.Decimal(1) for _ in range(10)]) + w /= w.sum() + assert_almost_equal(a.mean(0), average(a, weights=w)) + class TestSelect(TestCase): choices = [np.array([1, 2, 3]), np.array([4, 5, 6]), |