<div dir="auto">There is an issue that suggests reimplementing many of the Generator methods as ufuncs so they they would inherit all of the free features of ufuncs. It seems like a doable but large project for some useful but nonessential features.<div dir="auto"><br></div><div dir="auto">Kevin</div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 30, 2021, 20:49 Robert Kern <<a href="mailto:robert.kern@gmail.com">robert.kern@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">On Wed, Jun 30, 2021 at 3:34 PM Yoann Mocquin <<a href="mailto:mocquin@me.com" target="_blank" rel="noreferrer">mocquin@me.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><br><br>Hello there,<div><br></div><div>here is a feature request for the possibility to wrap numpy random distributions to be wrapped by a mechanism like __array_function__ or __array_ufunc__. You can find the GH issue at : <a href="https://github.com/numpy/numpy/issues/19382" target="_blank" rel="noreferrer">https://github.com/numpy/numpy/issues/19382</a>.</div><div><br></div><div><br></div><div><br></div><div><div>This post follows [this one](<a href="https://github.com/numpy/numpy/issues/18902" target="_blank" rel="noreferrer">https://github.com/numpy/numpy/issues/18902</a>). I figured I should open another issue for `np.random.normal`, but this applies for all distributions I guess.</div><div><br></div><div>## Feature</div><div><br></div><div>Basicaly, I would like that `numpy.random.*` distributions could trigger an interface when passed instances from custom classes, "à la" `__array_ufunc__` or `__array_function__`. Here is an example concept : </div></div></div></blockquote><div><br></div><div> The main problem is that these are not functions but methods on a hidden global `RandomState` instance. I haven't kept up fully with all of the efforts in the `__array_*__` proposals, but I do see that methods are explicitly excluded from the `__array_function__` mechanism:</div><div><br></div><div>  <a href="https://numpy.org/neps/nep-0018-array-function-protocol.html#non-goals" target="_blank" rel="noreferrer">https://numpy.org/neps/nep-0018-array-function-protocol.html#non-goals</a></div><div><br></div><div>The `RandomState` functionality (and thus all of these aliases in `numpy.random`) are now frozen in functionality (per NEP 19), so we will not be adding this functionality to them. If the `__array_function__` developments eventually work out a good way to wrap methods, then we can think about using that on `Generator`, but I suspect that will not be straightforward.</div></div><div><br></div>-- <br><div dir="ltr">Robert Kern</div></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank" rel="noreferrer">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div>