[Numpy-discussion] Strange behavior with boolean slices...

Cera, Tim tim@cerazone....
Sun Aug 25 19:30:47 CDT 2013


I have done this before, but am now really confused.

Created an array 'day' specifying the 'f' type

In [29]: day
Out[29]: array([ 5.,  5.], dtype=float32)

# Have a mask...
In [30]: mask
Out[30]: array([ True, False], dtype=bool)

# So far, so good...
In [31]: day[mask]
Out[31]: array([ 5.], dtype=float32)

In [32]: day[mask] = 10

# What?
In [33]: day
Out[33]: array([ 10.,  10.], dtype=float32)


So I created an integer array 'a'

In [38]: a
Out[38]: array([11,  1])

In [39]: a[mask]
Out[39]: array([11])

In [40]: a[mask] = 12

# This is what I expect.
In [41]: a
Out[41]: array([12,  1])

Am I missing something?  Is this supposed to happen?

Version 1.7.1.

Kindest regards,
Tim


More information about the NumPy-Discussion mailing list