Hi,
On Apr 23, 2007, at 11:30 AM, Tommy Grav wrote:
I have two arrays:
a = numpy.array([0,1,2,3,4,5,6,7,8,9])
b = numpy.array([0,0,1,1,2,2,0,1,2,3])
I would like to get the part of a that corresponds
to where b is equal to i.
For example:
i = 0 = ([0,1,6])
i = 1 = ([2,3,7])
On Monday 23 April 2007 10:37:57 Mark.Miller wrote:
Greetings:
In some of my code, I need to use large matrix of random numbers that
meet specific criteria (i.e., some random numbers need to be removed and
replaces with new ones).
I have been working with .any() and .where() to facilitate
I have two arrays:
a = numpy.array([0,1,2,3,4,5,6,7,8,9])
b = numpy.array([0,0,1,1,2,2,0,1,2,3])
I would like to get the part of a that corresponds
to where b is equal to i.
For example:
i = 0 = ([0,1,6])
i = 1 = ([2,3,7])
a[b == 1]
and
a[b == 0]
work too, btw.
-steve
Excellent suggestions...just a few comments:
Pierre GM wrote:
On Monday 23 April 2007 10:37:57 Mark.Miller wrote:
Greetings:
In some of my code, I need to use large matrix of random numbers that
meet specific criteria (i.e., some random numbers need to be removed and
replaces with new
Mark.Miller wrote:
Pierre GM wrote:
a[a0] = numpy.random.normal(0,1)
This is a neat construct that I didn't realize was possible. However,
it has the undesirable (in my case) effect of placing a single new
random number in each locations where a0. While this could work, I
ideally
Have you tried nonzero() ?
Nonzero isn't quite what I'm after, as the tests are more complicated
than what I illustrated in my example.
Tests such as (a0)(b1) will give you arrays of booleans. The nonzero give
you where the two conditions are met (viz, where the results is True, or 1)
When you say no python temps I guess you mean, no temporary
*variables*? If I understand correctly, this allocates a temporary
boolean array to hold the result of a0.
Indeed, hence my precising no *python* temps. There still be a tmp created
at one point or another (if I'm not mistaken)
Robert Kern wrote:
Certainly. How about this?
mask = (a0)
a[mask] = numpy.random.normal(0, 1, size=mask.sum())
That's slick. I believe it's precisely what I'm after.
Appreciate it,
-Mark
___
Numpy-discussion mailing list
On 23/04/07, Pierre GM [EMAIL PROTECTED] wrote:
Note that in addition of the bitwise operators, you can use the logical_
functions. OK, you'll still end up w/ temporaries, but I wonder whether there
couldn't be some tricks to bypass that...
If you're really determined not to make many temps,
Hi,
I thought I remembered there was a way to reshape in-place an array, but
neither google, nor greping my mailbox brings anything out.
Am I wrong, or is there indeed a way to reshape in-place an array ?
Cheers,
Gaƫl
___
Numpy-discussion mailing list
On 4/23/07, Gael Varoquaux [EMAIL PROTECTED] wrote:
Hi,
I thought I remembered there was a way to reshape in-place an array, but
neither google, nor greping my mailbox brings anything out.
Am I wrong, or is there indeed a way to reshape in-place an array ?
Just set the shape of the array:
On Mon, Apr 23, 2007 at 10:20:43AM -0700, Timothy Hochberg wrote:
Just set the shape of the array:
somearray.shape = newshape
Of course ! Thanks
On Mon, Apr 23, 2007 at 12:20:51PM -0500, Robert Kern wrote:
.reshape()
Unless I miss something obvious a.reshape() doesn't modify a,
Gael Varoquaux wrote:
On Mon, Apr 23, 2007 at 12:20:51PM -0500, Robert Kern wrote:
.reshape()
Unless I miss something obvious a.reshape() doesn't modify a, which is
somewhat missleading, IMHO.
Nope, you caught me in a moment of stupidity.
--
Robert Kern
I have come to believe that the
On Monday 23 April 2007 13:36:26 Christopher Barker wrote:
Gael Varoquaux wrote:
Unless I miss something obvious a.reshape() doesn't modify a, which is
somewhat missleading, IMHO.
quite correct. .reshape() creates a new array that shared data with the
original:
Mmh. My understanding is
El dl 23 de 04 del 2007 a les 12:47 -0400, en/na Anne Archibald va
escriure:
On 23/04/07, Pierre GM [EMAIL PROTECTED] wrote:
Note that in addition of the bitwise operators, you can use the logical_
functions. OK, you'll still end up w/ temporaries, but I wonder whether
there
couldn't
On 4/23/07, Christopher Barker [EMAIL PROTECTED] wrote:
Charles R Harris wrote:
Here's a better doc string that explains This will be a new view
object if possible; otherwise, it will return a copy.
Does this exist somewhere, or are you contributing it now?
At the moment
Dear all,
this is odd:
import numpy as np
fact = 2825L * 86400L
nn = np.array([-20905000L])
nn
array([-20905000], dtype=int64)
nn[0] // fact
0
But:
long(nn[0]) // fact
-1L
Is this a bug in numpy, or in python's implementation of longs? I would
think both
Actually,
it happens for normal integers as well:
n = np.array([-5, -100, -150])
n // 100
array([ 0, -1, -1])
-5//100, -100//100, -150//100
(-1, -1, -2)
On Mon, April 23, 2007 22:20, Christian Marquardt wrote:
Dear all,
this is odd:
import numpy as np
fact =
Hmmm,
On Mon, April 23, 2007 22:29, Christian Marquardt wrote:
Actually,
it happens for normal integers as well:
n = np.array([-5, -100, -150])
n // 100
array([ 0, -1, -1])
-5//100, -100//100, -150//100
(-1, -1, -2)
and finally:
n % 100
array([95, 0, 50])
Keith Goodman wrote:
At the moment numpy.reshape and array.reshape have different doc
strings (I'm using numpy 1.0.2.dev3546). The one I pasted is from
numpy.reshape.
And I see from there:
:See also:
numpy.ndarray.reshape() is the equivalent method.
so it looks like they are the
On Apr 23, 2007, at 16:41 , Christian Marquardt wrote:
On Mon, April 23, 2007 22:29, Christian Marquardt wrote:
Actually,
it happens for normal integers as well:
n = np.array([-5, -100, -150])
n // 100
array([ 0, -1, -1])
-5//100, -100//100, -150//100
(-1, -1, -2)
and finally:
n
Christian Marquardt wrote:
Hello,
The following is what I expected...
y = 1234
x = array([1], dtype = uint64)
print x + y, (x + y).dtype.type
[1235] type 'numpy.uint64'
This is what you expect only because y is a scalar and cannot
determine the kind of the output.
But even C89 required that x == (x/y)*y + (x%y), and that's not the case
here.
w
On Mon, 23 Apr 2007, David M. Cooke wrote:
On Apr 23, 2007, at 16:41 , Christian Marquardt wrote:
On Mon, April 23, 2007 22:29, Christian Marquardt wrote:
Actually,
it happens for normal integers as well:
On 4/23/07, Travis Oliphant [EMAIL PROTECTED] wrote:
Christian Marquardt wrote:
Hello,
The following is what I expected...
y = 1234
x = array([1], dtype = uint64)
print x + y, (x + y).dtype.type
[1235] type 'numpy.uint64'
This is what you expect only because y is a
On 4/23/07, Charles R Harris [EMAIL PROTECTED] wrote:
On 4/23/07, Travis Oliphant [EMAIL PROTECTED] wrote:
Christian Marquardt wrote:
Hello,
The following is what I expected...
y = 1234
x = array([1], dtype = uint64)
print x + y, (x + y).dtype.type
[1235] type
25 matches
Mail list logo