[Numpy-discussion] inverse of compress

Vincent Schut schut@sarvision...
Wed Jul 21 03:00:30 CDT 2010


Hi,

I find myself often looking for a numpy function that would behave like 
an inverse compress. E.g. one that satisfies a.compress(mask) = b, given 
b and mask, creating a. Or like a createFromMask function, which would 
create an array with shape of a given boolean mask, and filling all 
elements that are True with values from b, b being a flat array the 
length of sum(mask). Currently I of course just first create a, then do 
a[mask] = b. Which works, but is ugly :-) So if anyone has a oneliner 
which I missed, please step forward...

regards,
Vincent Schut.



More information about the NumPy-Discussion mailing list