Hi,
25/11/10 @ 11:13 (+0100), thus spake Jean-Luc Menut:
I suppose that some of the difference may come from the default data
type of 64bits in numpy and 32 bits in IDL. Is there a way to change the
numpy default data type (without recompiling) ?
This is probably not the issue.
And I'm
22/11/10 @ 11:08 (-0800), thus spake Christopher Barker:
On 11/21/10 11:37 AM, Ernest Adrogué wrote:
so you want
t[:,x,y]
I tried that, but it's not the same:
In [307]: t[[0,1],x,y]
Out[307]: array([1, 7])
In [308]: t[:,x,y]
Out[308]:
array([[1, 3],
[5, 7]])
what
22/11/10 @ 11:20 (-0800), thus spake John Salvatier:
I didn't realize the x's and y's were varying the first time around.
There's probably a way to omit it, but I think the conceptually
simplest way is probably what you had to begin with. Build an index by
saying i = numpy.arange(0,
22/11/10 @ 14:04 (-0600), thus spake Robert Kern:
This way, I get the elements (0,1) and (1,1) which is what
I wanted. The question is: is it possible to omit the [0,1]
in the index?
No, but you can write generic code for it:
t[np.arange(t.shape[0]), x, y]
Thank you. This is what I
Hi,
Suppose an array of shape (N,2,2), that is N arrays of
shape (2,2). I want to select an element (x,y) from each one
of the subarrays, so I get a 1-dimensional array of length
N. For instance:
In [228]: t=np.arange(8).reshape(2,2,2)
In [229]: t
Out[229]:
array([[[0, 1],
[2, 3]],
Hi,
21/11/10 @ 11:28 (-0800), thus spake John Salvatier:
yes use the symbol ':'
so you want
t[:,x,y]
I tried that, but it's not the same:
In [307]: t[[0,1],x,y]
Out[307]: array([1, 7])
In [308]: t[:,x,y]
Out[308]:
array([[1, 3],
[5, 7]])
No?
--
Ernest
21/09/10 @ 12:55 (-0500), thus spake Gökhan Sever:
On Tue, Sep 21, 2010 at 12:43 PM, josef.p...@gmail.com wrote:
I'm a bit surprised, I think np.unique does some extra work to
maintain the order.
The tolist() might not be necessary if you iterate over rows.
Testing again with a
8/09/10 @ 15:35 (-0400), thus spake Anne Archibald:
2010/9/8 Ernest Adrogué eadro...@gmx.net:
I have a sorted, flat array:
In [139]: a =np.array([0,1,2,2,2,3])
Basically, I want views of the areas where there
are repeated numbers (since the array is sorted, they
will be contiguous
Hi,
How can it be done?
id() doesn't do it:
In [238]: a= np.arange(5)
In [239]: id(a) == id(a[:])
Out[239]: False
Any ideas?
Ernest
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
5/09/10 @ 21:25 (+0200), thus spake Gael Varoquaux:
On Sun, Sep 05, 2010 at 09:12:34PM +0200, Ernest Adrogué wrote:
Hi,
How can it be done?
np.may_share_memory
Thanks Gael and Puneeth.
I think the .base attribute is enough for what I want.
Bye
5/09/10 @ 15:59 (-0500), thus spake Robert Kern:
2010/9/5 Ernest Adrogué eadro...@gmx.net:
5/09/10 @ 21:25 (+0200), thus spake Gael Varoquaux:
On Sun, Sep 05, 2010 at 09:12:34PM +0200, Ernest Adrogué wrote:
Hi,
How can it be done?
np.may_share_memory
Thanks Gael and Puneeth
Hi,
I find this a bit odd:
In [18]: np.array(['a','b','c','d']) 'a'
Out[18]: array([False, True, True, True], dtype=bool)
In [19]: np.array(['a','b','c','d']) 4
Out[19]: True
In [20]: np.array(['a','b','c','d']) 4.5
Out[20]: True
Is that right? I was expecting an element-wise
31/08/10 @ 09:44 (-0700), thus spake Keith Goodman:
2010/8/31 Ernest Adrogué eadro...@gmx.net:
Hi,
I find this a bit odd:
In [18]: np.array(['a','b','c','d']) 'a'
Out[18]: array([False, True, True, True], dtype=bool)
In [19]: np.array(['a','b','c','d']) 4
Out[19]: True
19/08/10 @ 18:03 (-0600), thus spake Charles R Harris:
2010/8/19 Ernest Adrogué eadro...@gmx.net
Hi,
I was trying to use lexsort with an array of
datetime.date objects, but it doesn't seem to work.
In [86]: date = np.array([datetime.date(2000, 9, 17),
datetime.date(2000, 10, 1
Hi,
I was trying to use lexsort with an array of
datetime.date objects, but it doesn't seem to work.
In [86]: date = np.array([datetime.date(2000, 9, 17),
datetime.date(2000, 10, 1),
datetime.date(2000, 10, 22),
datetime.date(2000, 11, 1)])
In [90]: date
Out[90]: array([2000-09-17,
17/03/10 @ 11:47 (-0700), thus spake gerardob:
Let A and B be two n x n matrices.
I would like to have another n x n matrix C such that
C_ij = min {A_ij, B_ij}
Example:
A = numpy.array([[2,3],[10,12]])
B = numpy.array([[1,4],[9,13]])
Output
C = [[1,3],[9,12]]
The function
Hello everybody,
Suppose I want to find all 2-digit numbers whose first digit
is either 4 or 5, the second digit being 7, 8 or 9.
Is there a Numpy/Scipy function to calculate that kind of
combinations?
I came up with this function, the problem is it uses recursion:
def g(sets):
if len(sets)
4/03/10 @ 11:19 (+0100), thus spake Ernest Adrogué:
Hello everybody,
Suppose I want to find all 2-digit numbers whose first digit
is either 4 or 5, the second digit being 7, 8 or 9.
Is there a Numpy/Scipy function to calculate that kind of
combinations?
I came up with this function
4/03/10 @ 12:26 (+0100), thus spake Johan Grönqvist:
Ernest Adrogué skrev:
Suppose I want to find all 2-digit numbers whose first digit
is either 4 or 5, the second digit being 7, 8 or 9.
I came up with this function, the problem is it uses recursion:
[...]
In [157]: g([[4,5
28/02/10 @ 01:56 (-0500), thus spake David Warde-Farley:
On 26-Feb-10, at 8:12 AM, Ernest Adrogué wrote:
Thanks for the tip. I didn't know that...
Also, frompyfunc appears to crash python when the last argument is 0:
In [9]: func=np.frompyfunc(lambda x: x, 1, 0)
In [10]: func
Hi,
26/02/10 @ 11:23 (+0100), thus spake Ole Streicher:
Hi,
I want to apply a function to all indices of an array that fullfill a
certain condition.
What I tried:
-8
import numpy
def myfunc(x):
print 'myfunc of', x
a =
26/02/10 @ 13:31 (+0100), thus spake Ole Streicher:
Hello Ernest,
Ernest Adrogué eadro...@gmx.net writes:
It depends on what exactly you want to do. If you just want
to iterate over the array, try something liks this
for element in a[a 0.8]:
myfunc(element)
No; I need
26/02/10 @ 13:51 (+0200), thus spake Pauli Virtanen:
pe, 2010-02-26 kello 12:43 +0100, Ernest Adrogué kirjoitti:
[clip]
Or if you want to produce a different array of the same shape
as the original, then you probably need a vectorised function.
def myfunc(x):
print 'myfunc of', x
2/02/10 @ 00:01 (-0700), thus spake Charles R Harris:
On Mon, Feb 1, 2010 at 10:57 PM, josef.p...@gmail.com wrote:
On Tue, Feb 2, 2010 at 12:31 AM, Charles R Harris
charlesr.har...@gmail.com wrote:
On Mon, Feb 1, 2010 at 10:02 PM, josef.p...@gmail.com wrote:
On Mon, Feb 1,
Hello,
Consider the following code:
for j in range(5):
f = np.bincount(x[y == j])
It fails with MemoryError whenever y == j is all False element-wise.
In [96]: np.bincount([])
---
MemoryError
Hi,
Do you think it is sensible for np.equal to return a NotImplemented
object when is given an array of variable length dtype?
Consider this code:
x = np.array(['xyz','zyx'])
np.where(np.equal(x, 'zyx'), [0,0], [1,1])
the last line returns array([0, 0]) which is wrong. Compare with
np.where(x
26/01/10 @ 08:59 (-0500), thus spake josef.p...@gmail.com:
2010/1/26 Ernest Adrogué eadro...@gmx.net:
Hi,
Do you think it is sensible for np.equal to return a NotImplemented
object when is given an array of variable length dtype?
Consider this code:
x = np.array(['xyz','zyx
Hi,
I have a function where an array of integers (1-d) is compared
element-wise to an integer using the greater-than operator.
I noticed that when the integer is 0 it takes about 75% more time
than when it's 1 or 2. Is there an explanation?
Here is a stripped-down version which does (sort
20/01/10 @ 16:17 (-0600), thus spake Robert Kern:
2010/1/20 Ernest Adrogué eadro...@gmx.net:
Hi,
I have a function where an array of integers (1-d) is compared
element-wise to an integer using the greater-than operator.
I noticed that when the integer is 0 it takes about 75% more time
Hi,
This is hard to explain. In this code:
reduce(np.logical_or, [m1 m2, m1 m3, m2 m3])
where m1, m2 and m3 are boolean arrays, I'm trying to figure
out an expression that works with an arbitrary number of
arrays, not just 3. Any idea??
Bye.
___
18/01/10 @ 14:17 (-0500), thus spake josef.p...@gmail.com:
2010/1/18 Ernest Adrogué eadro...@gmx.net:
Hi,
This is hard to explain. In this code:
reduce(np.logical_or, [m1 m2, m1 m3, m2 m3])
where m1, m2 and m3 are boolean arrays, I'm trying to figure
out an expression
18/01/10 @ 13:18 (-0600), thus spake Warren Weckesser:
Ernest Adrogué wrote:
Hi,
This is hard to explain. In this code:
reduce(np.logical_or, [m1 m2, m1 m3, m2 m3])
where m1, m2 and m3 are boolean arrays, I'm trying to figure
out an expression that works with an arbitrary
12/01/10 @ 15:33 (-0500), thus spake Marc Schwarzschild:
I have a csv file like this:
Account, Symbol, Quantity, Price
One,SPY,5,119.00
One,SPY,3,120.00
One,SPY,-2,125.00
One,GE,...
One,GE,...
Two,SPY, ...
Three,GE, ...
...
The data is much
Hi,
I find myself doing this:
In [244]: x
Out[244]:
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
In [245]: y=x.copy()
In [251]: y.dtype.char
Out[251]: 'l'
In [252]: dt=np.dtype([('a','l'),('b','l'),('c','l')])
In [254]: y.dtype=dt
Is it okay?
The problem is that it's not easy to
12/12/09 @ 08:16 (-0800), thus spake Keith Goodman:
If a and b are as short as in your example, which I doubt, here's a faster
way:
timeit np.nonzero(reduce(np.logical_or, [a == i for i in b]))
10 loops, best of 3: 14 µs per loop
timeit [i for i, z in enumerate(a) if z in b]
10
Hi,
Suppose I have a flat array, and I want to know the
indices corresponding to values contained in a list
of arbitrary lenght.
Intuitively I would have done:
a = np.array([1,2,3,4])
np.nonzero(a in (0,2,4))
However the in operator doesn't work element-wise,
instead it compares the whole
9/12/09 @ 00:45 (-0500), thus spake josef.p...@gmail.com:
as long as all numbers are of the same type, you can create a view
that behaves (mostly) like a regular array
[...]
Thanks Josef. Great explanation. It's all clear now.
Ernest
___
Hi,
A few weeks ago there was a discussion about a
histogram_discrete() function --sorry for starting a new
thread but I have lost the mails.
Somebody pointed out that bincount() already can be used
to histogram discrete data (except that it doesn't work
with negative values).
I have just
13/11/09 @ 09:41 (+0200), thus spake Priit Laes:
Does anyone have a scenario where one would actually have both negative
and positive numbers (integers) in the list?
Yes: when you have a random variable that is the difference
of two (discrete) random variables. For example, if you measure
the
Hello there,
Given a masked array such as this one:
In [19]: x = np.ma.masked_equal([-1, -1, 0, -1, 2], -1)
In [20]: x
Out[20]:
masked_array(data = [-- -- 0 -- 2],
mask = [ True True False True False],
fill_value = 99)
When you make an assignemnt in the vein of x[x
21/09/09 @ 14:43 (-0400), thus spake Pierre GM:
On Sep 21, 2009, at 12:17 PM, Ryan May wrote:
2009/9/21 Ernest Adrogué eadro...@gmx.net
Hello there,
Given a masked array such as this one:
In [19]: x = np.ma.masked_equal([-1, -1, 0, -1, 2], -1)
In [20]: x
Out[20
Hi,
I have two 1-d arrays (a and b), and I want to create a
third 2-d array, whose rows are of the form a[i]*b:
c = np.zeros((len(a),b))
c[0] = a[0]*b
c[1] = a[1]*b
.
.
.
Is there an easy way to do this (e.g, without a loop)?
Thanks!
--
Ernest
___
5/09/09 @ 11:22 (-0600), thus spake Mark Wendell:
For example:
Say that C is a simple python class with a couple attributes and methods.
a = np.empty( (5,5), dtype=object)
for i in range(5):
for j in range(5):
a[i,j] = C(var1,var2)
First question: is there a quicker
31/08/09 @ 14:37 (-0400), thus spake Pierre GM:
On Aug 31, 2009, at 2:33 PM, Ernest Adrogué wrote:
30/08/09 @ 13:19 (-0400), thus spake Pierre GM:
I can't reproduce that with a recent SVN version (r7348). What
version
of numpy are you using ?
Version 1.2.1
That must
30/08/09 @ 13:19 (-0400), thus spake Pierre GM:
I can't reproduce that with a recent SVN version (r7348). What version
of numpy are you using ?
Version 1.2.1
--
Ernest
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
Hi there,
Here is a structured array with 3 fields each of which has 3 fields
in turn:
In [3]: desc = [('a',int), ('b',int), ('c',int)]
In [4]: desc = [('x',desc), ('y',desc), ('z',desc)]
With a regular ndarray it works just fine:
In [11]: x = np.zeros(2, dtype=desc)
In [12]: x['x']['b'] = 2
20/08/09 @ 18:00 (-0700), thus spake Dr. Phillip M. Feldman:
I have a 1-D array and would like to generate a list of indices for which a
given condition is satisfied. What is the cleanest way to do this?
you can do something like this:
numpy.arange(len(x))[x 5]
it'll give you the indices of
Hi,
Suppose I have a 3-dimansional array, where one dimension
is time. I'm not particularly interested in selecting specific
moments in time, so most of the time I won't be indexing this
dimension.
Intuitively, one would make time the third dimension, but if
you do that you have to specifiy the
18/08/09 @ 07:33 (-0700), thus spake Robert Kern:
2009/8/18 Ernest Adrogué eadro...@gmx.net:
Hi,
Suppose I have a 3-dimansional array, where one dimension
is time. I'm not particularly interested in selecting specific
moments in time, so most of the time I won't be indexing
29/07/09 @ 14:54 (-0700), thus spake Christopher Barker:
Robert Kern wrote:
2009/7/29 Ernest Adrogué eadro...@gmx.net:
Now, I need to be able to differentiate between 0 and 'no data'.
Is it possible to do this with the standard array class?
Not really. Use masked arrays. Or use
Hello,
Suppose I want to store some data (a non-negative integer)
related to an event involving two entities. It occurs to me that
the way to do it is using a 2-d array, like a table:
For example:
a b c
a1
b 2 0
c 5
in the event 'b-a' the data is 2, and in the event 'c-a' is
51 matches
Mail list logo