[Numpy-discussion] Summing an array with dtype=object
Sun Nov 15 23:16:44 CST 2009
On Sun, Nov 15, 2009 at 23:11, Pierre GM <email@example.com> wrote:
> An issue was recently raised about summing a MaskedArray with a np.object dtype. Turns out that the problem is numpy based:
> Let's sum using integers
>>>> type(np.sum([1,2,3], dtype=np.int32))
> <type 'numpy.int32'>
> Now, with a np.object dtype:
> <type 'int'>
> And we no longer have a np.object, but a regular Python int. Which, unfortunately for MaskedArray, does not have a view object (hence the bug).
> Is it the expected behavior ?
Yes. Wherever we can, we return the object itself rather than
In : a
Out: array([0, 1, 2], dtype=object)
In : type(a)
"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
More information about the NumPy-Discussion