[SciPy-user] what is simpliest way to create this boolean array

dmitrey openopt@ukr....
Thu Aug 30 03:59:26 CDT 2007


No, I meant a = array((True, True, ... True (m1 numbers), False, 
False,... False(m2 numbers), True, ...(m3 numbers), False, ...(m4 
numbers) ))

If I'll get nothing better than Stéfan propose I'll use the way
a = array(ones(m1+m2+m3+m4), bool)
a[m1:m1+m2]=False
a[m1+m2+m3:]=False
D



Angus McMorland wrote:
> On 30/08/2007, dmitrey <openopt@ukr.net> wrote:
>   
>> hi all,
>> what's the easiest way to create bool array that contains m1 True, m2
>> False, m3 True, m4 False?
>> Or (alternatively) creating same Python list instead.
>>     
>
> How about "n.array([bool(1 - (x % 2)) for x in xrange(length)])"?
>
> A.
>   



More information about the SciPy-user mailing list