[Numpy-discussion] ENH: ratio function to mimic diff

Joseph Fox-Rabinovitz jfoxrabinovitz at gmail.com
Sat Jul 29 19:32:37 EDT 2017


On Jul 29, 2017 12:55, "Nathaniel Smith" <njs at pobox.com> wrote:

I'd also like to see a more detailed motivation for this.

And, if it is useful, then that would make 3 operations that have special
case pairwise moving window variants (subtract, floor_divide, true_divide).
3 is a lot of special cases. Should there instead be a generic mechanism
for doing this for arbitrary binary operations?


Perhaps another method for ufuncs of two arguments? I agree that there
should be a generic mechanism since a lack of one is what is preventing me
from applying this to masked arrays immediately. It would have to take in
some domain filter, like many of the translated masked functions do. A
ufunc could provide that transparently.


-n

On Jul 28, 2017 3:25 PM, "Joseph Fox-Rabinovitz" <jfoxrabinovitz at gmail.com>
wrote:

> I have created PR#9481 to introduce a `ratio` function that behaves very
> similarly to `diff`, except that it divides successive elements instead of
> subtracting them. It has some handling built in for zero division, as well
> as the ability to select between `/` and `//` operators.
>
> There is currently no masked version. Perhaps someone could suggest a
> simple mechanism for hooking np.ma.true_divide and np.ma.floor_divide in as
> the operators instead of the regular np.* versions.
>
> Please let me know your thoughts.
>
> Regards,
>
>     -Joe
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion at python.org
https://mail.python.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20170729/859f6ef6/attachment-0001.html>


More information about the NumPy-Discussion mailing list