[SciPy-User] Scipy and information theory

Ralf Gommers ralf.gommers at gmail.com
Sun Nov 10 21:26:58 EST 2019


On Sun, Nov 10, 2019 at 5:25 PM Robert Lucente - Pipeline.Com <
rlucente at pipeline.com> wrote:

> > Because I want to avoid long (and slow) for loops and take advantage of
> numpy/ scipy element wise operations
> I am embarrassed
>
> That was an amateur mistake on my part :-(
>
> -----Original Message-----
> From: SciPy-User <scipy-user-bounces+rlucente=pipeline.com at python.org> On
> Behalf Of Iyán Méndez Veiga
> Sent: Sunday, November 10, 2019 7:30 AM
> To: SciPy Users List <scipy-user at python.org>
> Subject: Re: [SciPy-User] Scipy and information theory
>
> El viernes, 8 de noviembre de 2019 18:13:32 (CET) Robert Lucente -
> Pipeline.Com escribió:
> > Why not use Python's built in fcn?
> >
> > https://docs.python.org/3/library/math.html#math.log2
> >
> > math.log2(x)
>
> Because I want to avoid long (and slow) for loops and take advantage of
> numpy/ scipy element wise operations. That is why I prefer numpy.log2(x)
> over math.log2(x). My x is a high dimension array, not a scalar.
>
> > This does sound like a useful feature to add to these functions. I'm
> > not sure how easy it is to add a keyword to those functions though,
> > since the ufunc machinery may be limited in flexibility. Maybe someone
> > else can say straight away. If you want to start looking into
> > implementing this, here are some notes of where to start:
> > http://scipy.github.io/devdocs/dev/core-dev/index.html#scipy-special
>
> Thanks Ralf, I'll have a look. Also waiting if someone else can say if it
> would be easy or hard to implement.
>

Right after I wrote that Josh just posted
https://github.com/scipy/scipy/issues/11029#issuecomment-551968035, which
states "to add a keyword argument ... and the current Cython special
codegen can’t handle that automatically". So I think that confirms what I
suspected: it's not really doable right now. Adding a new function is not
justified; a Python wrapper could be but it's not great for performance -
you could try that and keep the overhead for the current default behavior
is low as possible, then report some benchmark result. That should help us
decide. Probably best to open an issue or PR for that for further
discussion.

Cheers,
Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-user/attachments/20191110/e09b3ee9/attachment.html>


More information about the SciPy-User mailing list