[Numpy-discussion] Summing an array with dtype=object
Sun Nov 15 23:30:29 CST 2009
On Nov 16, 2009, at 12:16 AM, Robert Kern wrote:
> On Sun, Nov 15, 2009 at 23:11, Pierre GM <firstname.lastname@example.org> 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
> np.object_ scalars.
OK, thank you Robert!
More information about the NumPy-Discussion