interval wrapping / remainder / angle normalization
Hi everyone! I was wondering if it is a possible addition to numpy to have a function to wrap values to an interval. Typically, it is desired to limit an angle to [0, 2pi) or [-pi ,pi), either by letting it "overflow" or by "bouncing" hence and forth. The function which does this is actually really simple. However, whenever I am facing this task I tend to work a while on this until I get it correct. I have a small and handy function (it is small because it just uses np.divmod) at hand which does this, including also the left-open or closed cases, and some tests. In case this is of interest, I can contribute. Best regards, Thomas.
I have similar needs, but for int array and integer interval (like -32768~32767), currently I'm using bitwise and/or (&/|) to do this trick. It will be nice if there is an optimized function, both for float and int -- Sent from: http://numpy-discussion.10968.n7.nabble.com/
When I understand correctly and what you desire is equivalent to integer
overflowing, the function can indeed be applied as well.
I tested.
But to be sure, maybe some examples are better.
Am Do., 20. Mai 2021 um 03:22 Uhr schrieb ZinGer_KyoN : I have similar needs, but for int array and integer interval (like
-32768~32767), currently I'm using bitwise and/or (&/|) to do this trick. It will be nice if there is an optimized function, both for float and int --
Sent from: http://numpy-discussion.10968.n7.nabble.com/
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion
participants (2)
-
Thomas Hilger
-
ZinGer_KyoN