On Mon, 2024-03-25 at 13:49 +, percynichols...@gmail.com wrote:
> Many thanks!
>
> Just one more inquiry along those lines, if I may. The code asserts
> that clip should outpace np.maximum(mp.minumum(arr, max), min).
> Despite this:
> *time a = np.arange(100)it.clip(4, 20) # 8.48 µs
>
Many thanks!
Just one more inquiry along those lines, if I may. The code asserts that clip
should outpace np.maximum(mp.minumum(arr, max), min). Despite this:
*time a = np.arange(100)it.clip(4, 20)# 8.48 µs
%timeit np.maximum(np.minimum(a, 20), 4)2.09 nanoseconds
Will this be the norm?
> Also, can’t get __array_wrap__ to work. The arguments it receives after
> __iadd__ are all
> post-operation. Decided not to do it this way this time so not to hardcode
> such functionality
> into the class, but if there is a way to robustly achieve this it would be
> good to know.
It is
Thanks,
True, clip does get faster, but threshold is around 10k on my PC.
Also, can’t get __array_wrap__ to work. The arguments it receives after
__iadd__ are all post-operation. Decided not to do it this way this time so not
to hardcode such functionality into the class, but if there is a way
On Sun, Mar 10, 2024 at 9:14 AM Dom Grigonis wrote:
> Much thanks!
>
> Another related question while I am at it. It says clip is supposed to be
> faster than np.maximum(mp.minumum(arr, max), min). However:
>
> a = np.arange(100)%timeit a.clip(4, 20)# 8.48 µs%timeit
>
Much thanks!
Another related question while I am at it. It says clip is supposed to be
faster than np.maximum(mp.minumum(arr, max), min). However:
a = np.arange(100)
%timeit a.clip(4, 20)# 8.48 µs
%timeit np.maximum(np.minimum(a, 20), 4)# 2.09 µs
Is this expected?
Regards,
dg
> On 10
On Sat, Mar 9, 2024 at 11:23 PM Dom Grigonis wrote:
> Hello,
>
> Can't find answer to this anywhere.
>
> What I would like is to automatically clip the values if they breach the
> bounds.
>
> I have done a simple clipping, and overwritten __iadd__, __isub__,
> __setitem__, …
>
> But I am