>
>
>
> In [1]: a = np.array([0, 2, 4, 1, 3, 0, 3, 4, 0, 1])
>
> In [2]: lim = 2
>
> In [3]: np.sign(a - lim)
> Out[3]: array([-1, 0, 1, -1, 1, -1, 1, 1, -1, -1])
>
Dooh. Facepalm. I should have thought of that myself! Only one intermediate
array needs to be created then. Thank you. That was
>
>
>
> If there are no NaNs, you only need to make 2 masks by using ones
> instead of empty. Not elegent but a little faster.
>
Good point! Thanks.
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy
[Please pardon the piggybacking. I didn't get the original.]
On Thu, Sep 17, 2009 at 15:19, Keith Goodman wrote:
> On Thu, Sep 17, 2009 at 1:13 PM, Kim Hansen wrote:
>> Hi,
>>
>> Is there an array-like function equivalent with the builtin method for the
>> Python single-valued comparison cmp(x,y
On Thu, Sep 17, 2009 at 1:13 PM, Kim Hansen wrote:
> Hi,
>
> Is there an array-like function equivalent with the builtin method for the
> Python single-valued comparison cmp(x,y)?
>
> What I would like is a cmp(a, lim), where a is an ndarray and lim is a
> single value, and then I need an array ba
Hi,
Is there an array-like function equivalent with the builtin method for the
Python single-valued comparison cmp(x,y)?
What I would like is a cmp(a, lim), where a is an ndarray and lim is a
single value, and then I need an array back of a's shape giving the
elementwise comparison
array([cmp(a[0