[Numpy-discussion] Initial implementation of histogram_discrete()

josef.pktd at gmail.com josef.pktd at gmail.com
Thu Nov 12 20:12:42 EST 2009


On Thu, Nov 12, 2009 at 6:31 PM, Robert Kern <robert.kern at gmail.com> wrote:
> On Thu, Nov 12, 2009 at 17:25,  <josef.pktd at gmail.com> wrote:
>
>> If I could make a related wish, I wish np.bincount to take also a 2d
>> array as weights.
>
> It does.

If it does, I don't manage to make it work, and the new docs say 1dimension.

Josef

>>> np.bincount(np.array([[1,1],[0,0]]), weights=np.arange(4).reshape((2,2)))
Traceback (most recent call last):
ValueError: object too deep for desired array
>>> np.bincount(np.array([[1,1],[0,0]]))
Traceback (most recent call last):
ValueError: object too deep for desired array
>>> np.bincount(np.array([[1,1],[0,0]]).ravel())
array([2, 2])
>>> np.bincount(np.array([1,1,0,0]),np.arange(8).reshape((2,4)))
Traceback (most recent call last):
ValueError: object too deep for desired array
>>> np.bincount(np.array([1,1,0,0]),np.arange(8).reshape((4,2)))
Traceback (most recent call last):
ValueError: object too deep for desired array
>>> np.bincount(np.array([1,1,0,0]),np.arange(4))
array([ 5.,  1.])


>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



More information about the NumPy-Discussion mailing list