summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2007-04-02 18:25:50 +0000
committerTravis Oliphant <oliphant@enthought.com>2007-04-02 18:25:50 +0000
commita1f65e154f15f1c5b35c2befaeb74f3952b2c3e2 (patch)
tree0dbde984312d3ffbdf7fd940d5090e6848c8c530 /numpy/lib/tests/test_function_base.py
parent471ee74d8a32267d438f20074c077efb3b057ee7 (diff)
downloadnumpy-a1f65e154f15f1c5b35c2befaeb74f3952b2c3e2.tar.gz
Add patch in Ticket #189 for histogramdd. Fixes bug reported by Ben Granett
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 25a252862..a8d9296a6 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -365,7 +365,7 @@ class test_histogramdd(NumpyTestCase):
[.5, .5, 1.5], [.5, 1.5, 2.5], [.5, 2.5, 2.5]])
H, edges = histogramdd(x, (2,3,3), range = [[-1,1], [0,3], [0,3]])
answer = asarray([[[0,1,0], [0,0,1], [1,0,0]], [[0,1,0], [0,0,1], [0,0,1]]])
- assert(all(H == answer))
+ assert_array_equal(H,answer)
# Check normalization
ed = [[-2,0,2], [0,1,2,3], [0,1,2,3]]
H, edges = histogramdd(x, bins = ed, normed = True)
@@ -383,6 +383,27 @@ class test_histogramdd(NumpyTestCase):
[[0,0],[0,0],[0,0]]])
assert_array_equal(H, answer)
+ Z = zeros((5,5,5))
+ Z[range(5), range(5), range(5)] = 1.
+ H,edges = histogramdd([arange(5), arange(5), arange(5)], 5)
+ assert_array_equal(H, Z)
+
+ def check_shape(self):
+ x = rand(100,3)
+ hist3d, edges = histogramdd(x, bins = (5, 7, 6))
+ assert_array_equal(hist3d.shape, (5,7,6))
+
+ def check_weights(self):
+ v = rand(100,2)
+ hist, edges = histogramdd(v)
+ n_hist, edges = histogramdd(v, normed=True)
+ w_hist, edges = histogramdd(v, weights=ones(100))
+ assert_array_equal(w_hist, hist)
+ w_hist, edges = histogramdd(v, weights=ones(100)*2, normed=True)
+ assert_array_equal(w_hist, n_hist)
+ w_hist, edges = histogramdd(v, weights=ones(100, int)*2)
+ assert_array_equal(w_hist, 2*hist)
+
class test_unique(NumpyTestCase):
def check_simple(self):