Ideally, I would like in1d to always be the right answer to this problem. It
should be easy to put in an if statement to switch to a kern_in()-type
function
in the case of large ar1 but small ar2. I will do some timing tests and make
a
patch.
I uploaded a timing test and a patch
Nathaniel Smith njs at pobox.com writes:
On Fri, Aug 27, 2010 at 1:35 PM, Robert Kern robert.kern at gmail.com
wrote:
As valid gets larger, in1d() will catch up but for smallish sizes of
valid, which I suspect given the non-numeric nature of the OP's (Hi,
Brett!) request, kern_in() is
2010/8/27 Brett Olsen brett.ol...@gmail.com:
If there's multiple possible valid values, I've come up with a couple
possible methods, but they all seem to be inefficient or kludges:
valid = N.array((a, c))
(ar == valid[0]) | (ar == valid[1])
array([ True, False, True, False, False, True,
2010/8/27, Robert Kern robert.k...@gmail.com:
[~]
|2 def kern_in(x, valid):
.. mask = np.zeros(x.shape, dtype=bool)
.. for good in valid:
.. mask |= (x == good)
.. return mask
..
[~]
|6 ar = np.random.randint(100, size=100)
[~]
|7 valid = np.arange(0, 100, 5)
On Fri, Aug 27, 2010 at 3:58 PM, Brett Olsen brett.ol...@gmail.com wrote:
Hello,
I have an array of non-numeric data, and I want to create a boolean
array denoting whether each element in this array is a valid value
or not. This is straightforward if there's only one possible valid
value:
On Fri, Aug 27, 2010 at 15:10, Ken Watford kwatford+sc...@gmail.com wrote:
On Fri, Aug 27, 2010 at 3:58 PM, Brett Olsen brett.ol...@gmail.com wrote:
Hello,
I have an array of non-numeric data, and I want to create a boolean
array denoting whether each element in this array is a valid value
On Fri, Aug 27, 2010 at 1:17 PM, Robert Kern robert.k...@gmail.com wrote:
But in any case, that would be very slow for large arrays since it
would invoke a Python function call for every value in ar. Instead,
iterate over the valid array, which is much shorter:
mask = np.zeros(ar.shape,
On 27 August 2010 16:17, Robert Kern robert.k...@gmail.com wrote:
On Fri, Aug 27, 2010 at 15:10, Ken Watford kwatford+sc...@gmail.com wrote:
On Fri, Aug 27, 2010 at 3:58 PM, Brett Olsen brett.ol...@gmail.com wrote:
Hello,
I have an array of non-numeric data, and I want to create a boolean
On Fri, Aug 27, 2010 at 4:17 PM, Robert Kern robert.k...@gmail.com wrote:
On Fri, Aug 27, 2010 at 15:10, Ken Watford kwatford+sc...@gmail.com wrote:
On Fri, Aug 27, 2010 at 3:58 PM, Brett Olsen brett.ol...@gmail.com wrote:
Hello,
I have an array of non-numeric data, and I want to create a
On Fri, Aug 27, 2010 at 15:21, Nathaniel Smith n...@pobox.com wrote:
On Fri, Aug 27, 2010 at 1:17 PM, Robert Kern robert.k...@gmail.com wrote:
But in any case, that would be very slow for large arrays since it
would invoke a Python function call for every value in ar. Instead,
iterate over the
On Fri, Aug 27, 2010 at 1:35 PM, Robert Kern robert.k...@gmail.com wrote:
[~]
|8 %timeit kern_in(ar, valid)
10 loops, best of 3: 115 ms per loop
[~]
|9 %timeit np.in1d(ar, valid)
1 loops, best of 3: 279 ms per loop
As valid gets larger, in1d() will catch up but for smallish sizes of
It is obvious to me that True+False == True,. Why do you think it should
be False?
Nadav
On Thu, 2009-11-26 at 14:20 +0100, Nils Wagner wrote:
Hi all,
is the following behaviour correct
a = array(([True,True],[True,True]))
b = array(([False,False],[False,False]))
a+b
array([[
Le jeudi 26 novembre 2009 à 18:26 +0200, Nadav Horesh a écrit :
It is obvious to me that True+False == True,. Why do you think it should
be False?
I would understand it is not obvious that '+' stands for logical 'or',
and '*' for logical 'and'...
--
Fabrice Silva si...@lma.cnrs-mrs.fr
LMA
On Thu, Nov 26, 2009 at 02:43:14PM +0100, Fabrice Silva wrote:
Le jeudi 26 novembre 2009 à 18:26 +0200, Nadav Horesh a écrit :
It is obvious to me that True+False == True,. Why do you think it should
be False?
I would understand it is not obvious that '+' stands for logical 'or',
and '*'
On 11/26/2009 8:20 AM, Nils Wagner wrote:
a = array(([True,True],[True,True]))
b = array(([False,False],[False,False]))
a+b
NumPy's boolean operations are very well behaved.
a = np.array(([True,True],[True,True]))
a+a
array([[ True, True],
[ True, True]], dtype=bool)
Compare
Le jeudi 26 novembre 2009 à 14:44 +0100, Gael Varoquaux a écrit :
On Thu, Nov 26, 2009 at 02:43:14PM +0100, Fabrice Silva wrote:
Le jeudi 26 novembre 2009 à 18:26 +0200, Nadav Horesh a écrit :
It is obvious to me that True+False == True,. Why do you think it should
be False?
I would
On Thu, 26 Nov 2009 15:14:04 +0100
Fabrice Silva si...@lma.cnrs-mrs.fr wrote:
Le jeudi 26 novembre 2009 à 14:44 +0100, Gael Varoquaux
a écrit :
On Thu, Nov 26, 2009 at 02:43:14PM +0100, Fabrice Silva
wrote:
Le jeudi 26 novembre 2009 à 18:26 +0200, Nadav Horesh
a écrit :
It is obvious
On Thu, Nov 26, 2009 at 7:35 PM, Nils Wagner
nwag...@iam.uni-stuttgart.de wrote:
Sorry, I mixed up '+' and ''
a = array(([True,True],[True,True]))
b = array(([False,False],[False,False]))
a b
array([[False, False],
[False, False]], dtype=bool)
Cheers,
Nils
hey,
18 matches
Mail list logo