[Numpy-discussion] Initial implementation of histogram_discrete()
josef.pktd@gmai...
josef.pktd@gmai...
Thu Nov 12 19:12:42 CST 2009
On Thu, Nov 12, 2009 at 6:31 PM, Robert Kern <robert.kern@gmail.com> wrote:
> On Thu, Nov 12, 2009 at 17:25, <josef.pktd@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@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list