# [NumPy-Tickets] [NumPy] #1899: histogramdd improperly handles empty arrays with known bins

NumPy Trac numpy-tickets@scipy....
Fri Jul 8 22:39:02 CDT 2011

```#1899: histogramdd improperly handles empty arrays with known bins
------------------------+---------------------------------------------------
Reporter:  WeatherGod  |       Owner:  somebody
Type:  defect      |      Status:  new
Priority:  normal      |   Milestone:  Unscheduled
Component:  Other       |     Version:  1.6.0
Keywords:              |
------------------------+---------------------------------------------------
Subject says it all.  In particular, this impacts histogram2d.
histogramdd appears to attempt to handle this case, but doesn't do so
correctly.
{{{
>>> np.histogram2d([], [], bins=4)
(array([ 0.,  0.]), array([ 0.  ,  0.25,  0.5 ,  0.75,  1.  ]), array([ 0.
,  0.25,  0.5 ,  0.75,  1.  ]))
}}}
The first element of the return tuple is a 1-D array with two elements.
What is expected is a 2-D 4x4 array. Consider the following with non-empty
inputs:
{{{
>>> np.histogram2d([0.3], [0.7], bins=4)
(array([[ 0.,  0.,  0.,  0.],
[ 0.,  0.,  0.,  0.],
[ 0.,  0.,  1.,  0.],
[ 0.,  0.,  0.,  0.]]), array([-0.2 ,  0.05,  0.3 ,  0.55,  0.8 ]),
array([ 0.2 ,  0.45,  0.7 ,  0.95,  1.2 ]))
}}}
For comparison, consider how histogram behaves with empty inputs:
{{{
>>> np.histogram([], bins=4)
(array([0, 0, 0, 0]), array([ 0.  ,  0.25,  0.5 ,  0.75,  1.  ]))
}}}

--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1899>
NumPy <http://projects.scipy.org/numpy>
My example project
```