Re: [Numpy-discussion] Fancy indexing with masks

2011-09-20 Thread Robert Kern
2011/9/20 Stéfan van der Walt : > Hi all, > > Matthew Brett showed me an interesting code snippet this evening: > > # Construct input data > > In [15]: x > Out[15]: > array([[ 0,  1,  2], >       [ 3,  4,  5], >       [ 6,  7,  8], >       [ 9, 10, 11]]) > > # Fancy indexing with 1D boolean array >

Re: [Numpy-discussion] OS X Lion: llvm: numpy and scipy

2011-09-20 Thread Samuel John
Ralf, thanks for your answer. However, in short: I want `pip install numpy; pip install scipy` to work on OS X Lion without extra effort :-) On 19.09.2011, at 19:05, Ralf Gommers wrote: > Do you think it's possible to teach numpy to use different CC, CXX? > >> This is possible, but numpy pro

Re: [Numpy-discussion] Upgrade to 1.6.x: frompyfunc() ufunc casting issue

2011-09-20 Thread Aditya Sethi
Hi, Stefan, which version of Python and NumPy are you using? I am upgrading Python and NumPy, and would like to get it working on the official releases of Python 2.7.2 + NumPy 1.6.1 In Python 2.6 + NumPy 1.5.1 on win32, it works. In Python 2.7.2 + NumPy 1.6.1 on win32, np.frompyfunc(add,2,1).acc

Re: [Numpy-discussion] OS X Lion: llvm: numpy and scipy

2011-09-20 Thread David Cournapeau
On Tue, Sep 20, 2011 at 5:13 AM, Samuel John wrote: > Ralf, thanks for your answer. > > However, in short: > >  I want `pip install numpy; pip install scipy` to work on OS X Lion without > extra effort :-) > > > On 19.09.2011, at 19:05, Ralf Gommers wrote: >> Do you think it's possible to teach n

Re: [Numpy-discussion] Upgrade to 1.6.x: frompyfunc() ufunc casting issue

2011-09-20 Thread Olivier Delalleau
He is using the development version of Numpy, which is probably the main difference (I tried it too with Numpy 1.6.1 on an x86_64 Linux architecture and got the same bug). If you want to use an official Numpy release you'll probably need to downgrade to 1.5.x and wait until the next Numpy release.

Re: [Numpy-discussion] Upgrade to 1.6.x: frompyfunc() ufunc casting issue

2011-09-20 Thread Aditya Sethi
Understood. Thanks Olivier, Stefan. On Tue, Sep 20, 2011 at 9:18 AM, Olivier Delalleau wrote: > He is using the development version of Numpy, which is probably the main > difference (I tried it too with Numpy 1.6.1 on an x86_64 Linux architecture > and got the same bug). > If you want to use an

[Numpy-discussion] Dealing with arrays

2011-09-20 Thread DIPO ELEGBEDE
Hi All, I am extracting a list of lists from an application. In this case, my list has 12 lists. I then coverted each list into a numpy array. This returns 12 different arrays. Very well. The 12 different arrays are like as follows: [2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 1 2

Re: [Numpy-discussion] numpy blas running slow: how to check that it is properly linked

2011-09-20 Thread David Cottrell
Thanks, just getting back to this. I just checked again, and after setting my LD_LIBRARY_PATH properly, ldd shows _dotblas.so pointing and the sunmath and sunperf libraries. However the test_03.py still runs at about 8-9 seconds ... far too slow. ~/local/lib/python3.1/site-packages/numpy/core $ ld

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread Olivier Delalleau
Let's say your "list of lists" is called my_list, and assuming you are using python 2.7+: import collections import numpy for tmp_list in my_list: array = numpy.array(tmp_list) counts = collections.Counter(array) print counts Note that you don't even need to use numpy for that (you ca

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread dipo . elegbede
Thanks. There are other computations I have to do with numpy, hence the use. Second, I am on python 2.6. Any help? Sent from my BlackBerry wireless device from MTN -Original Message- From: Olivier Delalleau Sender: numpy-discussion-boun...@scipy.org Date: Tue, 20 Sep 2011 09:56:45 To

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread chico
What about: >>> listoflists = [[1,1,1], [1,2,3], [2,2,2]] >>> for eachlist in listoflists: ... print eachlist.count(1), eachlist.count(2), eachlist.count(3) ... 3 0 0 1 1 1 0 3 0 >>> Chico > Hi All, > > I am extracting a list of lists from an application. In this case, my list > has 12 lis

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread dipo . elegbede
Hi Chico, my list needs to be converted to a numpy array first before I do the count. Some other calculations rely on the count and its going to be built all on numpy. I have tried the collections.Counter() option but in python 2.6, the module collections has no Counter function. Anymore sug

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread G Jones
If you know the values that you want to count, you could just do: (data_array == value).sum() to find the number of times that "value" occurs in "data_array". You could use np.unique(data_array) to find the unique values and then count the number of occurrences of each value. On Tue, Sep 20, 201

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread josef . pktd
On Tue, Sep 20, 2011 at 10:06 AM, wrote: > Hi Chico, my list needs to be converted to a numpy array first before I do > the count. Some other calculations rely on the count and its going to be > built all on numpy. > > I have tried the collections.Counter() option but in python 2.6, the module

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread dipo . elegbede
Thanks Josef. This seems like a way to go except that it is giving extra values I don't need. For instance, it is also returning a count for 0s and as it were, I don't have zeros at all in my list. Second, I want a situation where, I can have a dictionary that has the figure and number of ti

[Numpy-discussion] sparse vectors / matrices / tensors

2011-09-20 Thread Yannick Versley
Hi all, I've been working quite a lot with sparse vectors and sparse matrices (basically as feature vectors in the context of machine learning), and have noticed that they do crop up in a lot of places (e.g. the CVXOPT library, in scikits, ...) and that people tend to either reinvent the wheel (i.

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread G Jones
data = [[1,2,1,1,4,2,1], [1,2,1,1,4,2,1,2,2,2,1,1,1],[1],[2]] def count_dict(arr): return dict([(x,(arr==x).sum()) for x in np.unique(arr)]) [count_dict(x) for x in data] yields: [{1: 4, 2: 2, 4: 1}, {1: 7, 2: 5, 4: 1}, {1: 1}, {2: 1}] not efficient, but it works On Tue, Sep 20, 2011 at 7:27

Re: [Numpy-discussion] sparse vectors / matrices / tensors

2011-09-20 Thread Christopher Jordan-Squire
On Tue, Sep 20, 2011 at 10:42 AM, Yannick Versley wrote: > Hi all, > I've been working quite a lot with sparse vectors and sparse matrices > (basically > as feature vectors in the context of machine learning), and have noticed > that they > do crop up in a lot of places (e.g. the CVXOPT library, i

Re: [Numpy-discussion] OS X Lion: llvm: numpy and scipy

2011-09-20 Thread Samuel John
Hi! On 20.09.2011, at 14:41, David Cournapeau wrote: > On Tue, Sep 20, 2011 at 5:13 AM, Samuel John wrote: >> Ralf, thanks for your answer. >> >> However, in short: >> >> I want `pip install numpy; pip install scipy` to work on OS X Lion without >> extra effort :-) [...] > I will try to look

Re: [Numpy-discussion] numpy blas running slow: how to check that it is properly linked

2011-09-20 Thread Olivier Delalleau
The blas implementation you are using may be slow. Here's my ldd on _dotblas.so, that shows it is using libblas (this is on Ubuntu 11.04): linux-vdso.so.1 => (0x7fffad5ff000) libblas.so.3gf => /usr/lib/libblas.so.3gf (0x7fc608ea4000) libc.so.6 => /lib/x86_64-linux-

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread Olivier Delalleau
Here's another python 2.6 version: import itertools import numpy for tmp_list in my_list: array = numpy.array(tmp_list) counts = dict((x, len(list(c))) for x, c in itertools.groupby(sorted(array))) print counts 2011/9/20 > Thanks. > There are other computations I have to do with nu

Re: [Numpy-discussion] sparse vectors / matrices / tensors

2011-09-20 Thread Yannick Versley
> > This question seems like it's more relevant to the scipy mailing list, > since scipy has scipy.sparse. > My point was that the current situation (i.e., people reinventing the wheel) was a by-product of the fact that there's nothing as standardized as numpy's ndarray or Python's buffer interface

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread DIPO ELEGBEDE
Thanks all for the very helpful answers. These answers all appear to have helped me in different ways especially in learning something new. I guess I didn't ask the right question after all. What I really want is a way to loop through individual arrays of the 12 arrays that I have. Here are my s

[Numpy-discussion] Comping Numpy in Cython

2011-09-20 Thread Sean Poust
I keep getting this error: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API" and a bunch of undefined variables when comping cython code with numpy I am new to cython and numpy and I am having trouble getting a *.pyx extension to compile with this in the header:

Re: [Numpy-discussion] Fancy indexing with masks

2011-09-20 Thread Stéfan van der Walt
On Tue, Sep 20, 2011 at 12:43 AM, Robert Kern wrote: > If the array is short in a dimension, it gets implicitly continued > with Falses. You can see this in one dimension: [...] > I honestly don't know if this is documented or tested anywhere or even > if this existed in older versions. The beh

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread Olivier Delalleau
2011/9/20 DIPO ELEGBEDE > 3. Get each array one after the other and work with it. (This is where the > problem is). > > How can I fetch out array1, then array2 then array3 up to array12? > > Is it possible to slice? > > Not really sure what your problem is, but since you should have now a list of

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread dipo . elegbede
Olivier, the code you sent did so much magic and I'm definitely using that. What baffles me is that looping through the 12 arrays seem impossible. I have tried what you just sent but it won't just work. You could confirm this. Sent from my BlackBerry wireless device from MTN -Original Mess

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread Olivier Delalleau
Can you please provide your current code, even if incomplete / not working? It's hard to tell what's wrong without looking at the code. -=- Olivier 2011/9/20 > Olivier, the code you sent did so much magic and I'm definitely using that. > What baffles me is that looping through the 12 arrays see

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread DIPO ELEGBEDE
I think that should sort it. def p(option_lists): for option_list in option_lists: array = numpy.array(option_list) for i in array: print i the option_lists here is the list of lists looping through it and then converting it into a numpy array is quiet easy. If I try to loop

Re: [Numpy-discussion] Dealing with arrays

2011-09-20 Thread Olivier Delalleau
I'm trying to understand what you want to do, but I'm afraid it's still not clear, so I'm sorry if that reply doesn't help either. It looks to me as if you first want to convert your list of lists into a list of arrays, then iterate through this list of arrays. If that's it, then you can just do:

Re: [Numpy-discussion] numpy blas running slow: how to check that it is properly linked

2011-09-20 Thread David Cournapeau
On Tue, Sep 20, 2011 at 9:56 AM, David Cottrell wrote: > Thanks, just getting back to this. I just checked again, and after > setting my LD_LIBRARY_PATH properly, ldd shows _dotblas.so pointing > and the sunmath and sunperf libraries. However the test_03.py still > runs at about 8-9 seconds ... fa

Re: [Numpy-discussion] numpy blas running slow: how to check that it is properly linked

2011-09-20 Thread David Cottrell
The test_03.py was basically a linalg.svd test (which I think is a linalg only routine?"). I guess for linalg checking, I should run ldd on lapack_lite.so? (included below). It's sounding like I need to get ATLAS up and running, but I'm still puzzled as to why the svd routine seems to be so much s

Re: [Numpy-discussion] numpy blas running slow: how to check that it is properly linked

2011-09-20 Thread David Cournapeau
On Tue, Sep 20, 2011 at 3:18 PM, David Cottrell wrote: > The test_03.py was basically a linalg.svd test (which I think is a > linalg only routine?"). I guess for linalg checking, I should run ldd > on lapack_lite.so? (included below). > > It's sounding like I need to get ATLAS up and running, but

Re: [Numpy-discussion] numpy blas running slow: how to check that it is properly linked

2011-09-20 Thread David Cournapeau
On Tue, Sep 20, 2011 at 1:18 PM, David Cournapeau wrote: > On Tue, Sep 20, 2011 at 9:56 AM, David Cottrell > wrote: >> Thanks, just getting back to this. I just checked again, and after >> setting my LD_LIBRARY_PATH properly, ldd shows _dotblas.so pointing >> and the sunmath and sunperf libraries

[Numpy-discussion] Fw: sparse vectors / matrices / tensors

2011-09-20 Thread Dinesh B Vadhia
Yannick Sounds great. Would cross-post on the Scipy list as that is where the scipy.sparse developers hang out. Dinesh From: Yannick Versley Sent: Tuesday, September 20, 2011 8:33 AM To: Discussion of Numerical Python Subject: Re: [Numpy-discussion] sparse vectors / matrices / tensors Th