Re: [Numpy-discussion] Adding fweights and aweights to numpy.corrcoef

2018-04-26 Thread josef . pktd
On Thu, Apr 26, 2018 at 11:59 AM, Sebastian Berg wrote: > I seem to recall that there was a discussion on this and it was a lot > trickier then expected. > But given that numpy has the weights already for cov, then I don't see any additional issues whith adding it also to corrcoef. corrcoef is

Re: [Numpy-discussion] Short-circuiting equivalent of np.any or np.all?

2018-04-26 Thread Sebastian Berg
On Thu, 2018-04-26 at 19:26 +0200, Sebastian Berg wrote: > On Thu, 2018-04-26 at 09:51 -0700, Hameer Abbasi wrote: > > Hi Nathan, > > > > np.any and np.all call np.or.reduce and np.and.reduce respectively, > > and unfortunately the underlying function (ufunc.reduce) has no way > > of detecting tha

Re: [Numpy-discussion] Short-circuiting equivalent of np.any or np.all?

2018-04-26 Thread Allan Haldane
On 04/26/2018 12:45 PM, Nathan Goldbaum wrote: > I'm curious if there's a way to get a fast early-terminating search in > NumPy? Perhaps there's another package I can depend on that does this? I > guess I could also write a bit of cython code that does this but so far > this project is pure python

Re: [Numpy-discussion] Short-circuiting equivalent of np.any or np.all?

2018-04-26 Thread Marten van Kerkwijk
For a lot more discussion, and a possible solution, see https://github.com/numpy/numpy/pull/8528 ___ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Short-circuiting equivalent of np.any or np.all?

2018-04-26 Thread Sebastian Berg
On Thu, 2018-04-26 at 09:51 -0700, Hameer Abbasi wrote: > Hi Nathan, > > np.any and np.all call np.or.reduce and np.and.reduce respectively, > and unfortunately the underlying function (ufunc.reduce) has no way > of detecting that the value isn’t going to change anymore. It’s also > used for (for

Re: [Numpy-discussion] Short-circuiting equivalent of np.any or np.all?

2018-04-26 Thread Nathan Goldbaum
On Thu, Apr 26, 2018 at 12:03 PM Joseph Fox-Rabinovitz < jfoxrabinov...@gmail.com> wrote: > Would it be useful to have a short-circuited version of the function that > is not a ufunc? > Yes definitely. I could use numba as suggested by Hameer but I'd rather not add a new runtime dependency. I cou

Re: [Numpy-discussion] Short-circuiting equivalent of np.any or np.all?

2018-04-26 Thread Joseph Fox-Rabinovitz
Would it be useful to have a short-circuited version of the function that is not a ufunc? - Joe On Thu, Apr 26, 2018 at 12:51 PM, Hameer Abbasi wrote: > Hi Nathan, > > np.any and np.all call np.or.reduce and np.and.reduce respectively, and > unfortunately the underlying function (ufunc.reduce)

Re: [Numpy-discussion] Short-circuiting equivalent of np.any or np.all?

2018-04-26 Thread Hameer Abbasi
Ah, in that case, if exotic platforms aren’t important for you, Numba can do the trick quite well. Best regards, Hameer Abbasi Sent from Astro for Mac On Apr 26, 2018 at 18:58, Nathan Goldbaum wrote: On Thu, Apr 26, 2018 at 11:52 AM Hameer Abbasi wrote: > Hi Na

Re: [Numpy-discussion] Short-circuiting equivalent of np.any or np.all?

2018-04-26 Thread Nathan Goldbaum
On Thu, Apr 26, 2018 at 11:52 AM Hameer Abbasi wrote: > Hi Nathan, > > np.any and np.all call np.or.reduce and np.and.reduce respectively, and > unfortunately the underlying function (ufunc.reduce) has no way of > detecting that the value isn’t going to change anymore. It’s also used for > (for e

Re: [Numpy-discussion] Short-circuiting equivalent of np.any or np.all?

2018-04-26 Thread Hameer Abbasi
Hi Nathan, np.any and np.all call np.or.reduce and np.and.reduce respectively, and unfortunately the underlying function (ufunc.reduce) has no way of detecting that the value isn’t going to change anymore. It’s also used for (for example) np.sum (np.add.reduce), np.prod (np.multiply.reduce), np.m

[Numpy-discussion] Short-circuiting equivalent of np.any or np.all?

2018-04-26 Thread Nathan Goldbaum
Hi all, I was surprised recently to discover that both np.any and np.all() do not have a way to exit early: In [1]: import numpy as np In [2]: data = np.arange(1e6) In [3]: print(data[:10]) [0. 1. 2. 3. 4. 5. 6. 7. 8. 9.] In [4]: %timeit np.any(data) 724 us +- 42.4 us per loop (mean +- std. de

Re: [Numpy-discussion] Adding fweights and aweights to numpy.corrcoef

2018-04-26 Thread Sebastian Berg
I seem to recall that there was a discussion on this and it was a lot trickier then expected. I think statsmodels might have options in this direction. - Sebastian On Thu, 2018-04-26 at 15:44 +, Corin Hoad wrote: > Hello, > > Would it be possible to add the fweights and aweights keyword > a

[Numpy-discussion] Adding fweights and aweights to numpy.corrcoef

2018-04-26 Thread Corin Hoad
Hello, Would it be possible to add the fweights and aweights keyword arguments from np.cov to np.corrcoef? They would retain their meaning from np.cov as frequency- or importance-based weightings respectively. Yours, Corin Hoad ___ NumPy-Discussion mail