Re: [Numpy-discussion] Bitwise operations and unsigned types

2012-04-05 Thread Charles R Harris
On Fri, Apr 6, 2012 at 12:19 AM, Travis Oliphant wrote: > > On Apr 6, 2012, at 1:01 AM, Charles R Harris wrote: > > > > On Thu, Apr 5, 2012 at 11:57 PM, Travis Oliphant wrote: > >> As of 1.5.1 this worked: >> >> >>> numpy.__version__ >> 1.5.1 >> >>> numpy.uint64(5) & 3 >> 1L >> >> >> So, this is a

Re: [Numpy-discussion] Bitwise operations and unsigned types

2012-04-05 Thread Travis Oliphant
> > Although 1.5.1 also gives > > >>> np.uint(3) + 4 > 7.0 > > i.e., a float, which certainly doesn't look right either. Whereas > > >>> np.int(3) + 4 > 7 > > The float promotion is still there in 1.6.1 > > In [4]: uint64(1) + 2 > Out[4]: 3.0 > > So I suppose there is the larger question is

Re: [Numpy-discussion] Bitwise operations and unsigned types

2012-04-05 Thread Charles R Harris
On Fri, Apr 6, 2012 at 12:01 AM, Charles R Harris wrote: > > > On Thu, Apr 5, 2012 at 11:57 PM, Travis Oliphant wrote: > >> As of 1.5.1 this worked: >> >> >>> numpy.__version__ >> 1.5.1 >> >>> numpy.uint64(5) & 3 >> 1L >> >> >> So, this is a regression and a bug. It should be fixed so that it >

Re: [Numpy-discussion] Bitwise operations and unsigned types

2012-04-05 Thread Travis Oliphant
On Apr 6, 2012, at 1:01 AM, Charles R Harris wrote: > > > On Thu, Apr 5, 2012 at 11:57 PM, Travis Oliphant wrote: > As of 1.5.1 this worked: > > >>> numpy.__version__ > 1.5.1 > >>> numpy.uint64(5) & 3 > 1L > > > So, this is a regression and a bug. It should be fixed so that it doesn't >

Re: [Numpy-discussion] Bitwise operations and unsigned types

2012-04-05 Thread Charles R Harris
On Thu, Apr 5, 2012 at 11:57 PM, Travis Oliphant wrote: > As of 1.5.1 this worked: > > >>> numpy.__version__ > 1.5.1 > >>> numpy.uint64(5) & 3 > 1L > > > So, this is a regression and a bug. It should be fixed so that it > doesn't raise an error. I believe the scalars were special cased so that

Re: [Numpy-discussion] Bitwise operations and unsigned types

2012-04-05 Thread Travis Oliphant
As of 1.5.1 this worked: >>> numpy.__version__ 1.5.1 >>> numpy.uint64(5) & 3 1L So, this is a regression and a bug. It should be fixed so that it doesn't raise an error. I believe the scalars were special cased so that a raw 3 would not be interpreted as a signed int when it is clearly uns

Re: [Numpy-discussion] Bitwise operations and unsigned types

2012-04-05 Thread Charles R Harris
On Thu, Apr 5, 2012 at 11:39 PM, Charles R Harris wrote: > > > On Thu, Apr 5, 2012 at 11:16 PM, Travis Oliphant wrote: > >> Which version of NumPy are you using. This could be an artefact of the >> new casting rules. >> >> This used to work. So, yes, this is definitely a bug. >> >> > It's beca

Re: [Numpy-discussion] Bitwise operations and unsigned types

2012-04-05 Thread Charles R Harris
On Thu, Apr 5, 2012 at 11:16 PM, Travis Oliphant wrote: > Which version of NumPy are you using. This could be an artefact of the > new casting rules. > > This used to work. So, yes, this is definitely a bug. > > It's because the '3' is treated as signed, so the uint64 needs to be cast to someth

Re: [Numpy-discussion] Bitwise operations and unsigned types

2012-04-05 Thread Travis Oliphant
Which version of NumPy are you using. This could be an artefact of the new casting rules. This used to work. So, yes, this is definitely a bug. -Travis On Apr 5, 2012, at 10:54 PM, Chris Laumann wrote: > Hi all- > > I've been trying to use numpy arrays of ints as arrays of bit fields

Re: [Numpy-discussion] Slice specified axis

2012-04-05 Thread Val Kalatsky
The only slicing short-cut I can think of is the Ellipsis object, but it's not going to help you much here. The alternatives that come to my mind are (1) manipulation of shape directly and (2) building a string and running eval on it. Your solution is better than (1), and (2) is a horrible hack, so

[Numpy-discussion] Bitwise operations and unsigned types

2012-04-05 Thread Chris Laumann
Hi all- I've been trying to use numpy arrays of ints as arrays of bit fields and mostly this works fine. However, it seems that the bitwise_* ufuncs do not support unsigned integer dtypes: In [142]: np.uint64(5)&3 --- Type

[Numpy-discussion] Improving NumPy's indexing / subsetting / fancy indexing implementation

2012-04-05 Thread Wes McKinney
dear all, I've routinely found that: 1) ndarray.take is up to 1 order of magnitude faster than fancy indexing 2) Hand-coded Cython boolean indexing is many times faster than ndarray indexing 3) putmask is significantly faster than ndarray indexing For example, I stumbled on this tonight: strai

Re: [Numpy-discussion] Can't access NumPy documentation elements

2012-04-05 Thread Pauli Virtanen
06.04.2012 00:57, Whitcomb, Mr. Tim kirjoitti: [clip] > Did something go wrong with a build? Seems so. As a workaround, you can read the documentation of the released versions. -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy

[Numpy-discussion] Can't access NumPy documentation elements

2012-04-05 Thread Whitcomb, Mr. Tim
Good afternoon - we're having some issues here accessing the online documentation for the latest NumPy version: 1. Search for "numpy asarray" on Google 2. Top result is "numpy.asarray - NumPy v1.7.dev-72185d3 Manual (DRAFT)" (or just go directly to link) 3. Click link - arrive at http://docs.sci

Re: [Numpy-discussion] MemoryError : with scipy.spatial.distance

2012-04-05 Thread Gael Varoquaux
On Thu, Apr 05, 2012 at 01:05:01PM -0700, Abhishek Pratap wrote: > Also in my case I dont really have a good approximate on value of K in > K-means. That's a hard problem, for which I have no answer, sorry :$ G ___ NumPy-Discussion mailing list NumPy-D

Re: [Numpy-discussion] MemoryError : with scipy.spatial.distance

2012-04-05 Thread Abhishek Pratap
Also in my case I dont really have a good approximate on value of K in K-means. -A On Thu, Apr 5, 2012 at 8:06 AM, Abhishek Pratap wrote: > Hi Gael > > The MemoryError exception I am getting is from using scikit's DBSCAN > implementation. I can check mini-batch implementation of Kmeans. > > Best

[Numpy-discussion] Slice specified axis

2012-04-05 Thread Tony Yu
Is there a way to slice an nd-array along a specified axis? It's easy to slice along a fixed axis, e.g.: axis = 0: >>> array[start:end] axis = 1: >>> array[:, start:end] ... But I need to do this inside of a function that accepts arrays of any dimension, and the user can operate on any axis of t

[Numpy-discussion] don't understand nditer

2012-04-05 Thread Neal Becker
Along the lines of my question about apply getitem to each element... If I try to use nditer, I seem to run into trouble: for d in np.nditer (y, ['refs_ok'],['readwrite']): : y[...].w = 2 : --- AttributeEr

Re: [Numpy-discussion] apply 'getitem to each element of obj array?

2012-04-05 Thread Olivier Delalleau
Le 5 avril 2012 12:50, Neal Becker a écrit : > Ken Watford wrote: > > > On Thu, Apr 5, 2012 at 11:57 AM, Olivier Delalleau > wrote: > >> Le 5 avril 2012 11:45, Neal Becker a écrit : > >> > >> You can do: > >> > >> f = numpy.frompyfunc(lambda x: x.some_attribute == 0, 1, 1) > >> > >> Then > >> f

Re: [Numpy-discussion] small bug in ndarray.flatten()?

2012-04-05 Thread Pierre Haessig
Sorry for the noise on the ML, I thougt I had made a private reply... -- Pierre Le 05/04/2012 18:53, Pierre Haessig a écrit : > Hi Chao, > > Le 05/04/2012 17:17, Chao YUE a écrit : >> nice to know this. can also use b.transpose().flatten() to circumvent it. > Just a short remark : b.T is a shorc

Re: [Numpy-discussion] small bug in ndarray.flatten()?

2012-04-05 Thread Pierre Haessig
Hi Chao, Le 05/04/2012 17:17, Chao YUE a écrit : > nice to know this. can also use b.transpose().flatten() to circumvent it. Just a short remark : b.T is a shorcut for b.transpose() ;-) Best, Pierre signature.asc Description: OpenPGP digital signature _

Re: [Numpy-discussion] apply 'getitem to each element of obj array?

2012-04-05 Thread Neal Becker
Ken Watford wrote: > On Thu, Apr 5, 2012 at 11:57 AM, Olivier Delalleau wrote: >> Le 5 avril 2012 11:45, Neal Becker a écrit : >> >> You can do: >> >> f = numpy.frompyfunc(lambda x: x.some_attribute == 0, 1, 1) >> >> Then >> f(array_of_objects_x) > > This is handy too: > > agetattr = numpy.fro

Re: [Numpy-discussion] apply 'getitem to each element of obj array?

2012-04-05 Thread Ken Watford
On Thu, Apr 5, 2012 at 11:57 AM, Olivier Delalleau wrote: > Le 5 avril 2012 11:45, Neal Becker a écrit : > > You can do: > > f = numpy.frompyfunc(lambda x: x.some_attribute == 0, 1, 1) > > Then > f(array_of_objects_x) This is handy too: agetattr = numpy.frompyfunc(getattr, 2, 1) array_of_value

Re: [Numpy-discussion] apply 'getitem to each element of obj array?

2012-04-05 Thread Olivier Delalleau
Le 5 avril 2012 11:45, Neal Becker a écrit : > Adam Hughes wrote: > > > If you are storing objects, then can't you store them in a list and just > do: > > > > for obj in objectlist: > > obj.attribute = value > > > > Or am I misunderstanding? > > > > It's multi-dimensional, and I wanted to av

Re: [Numpy-discussion] apply 'getitem to each element of obj array?

2012-04-05 Thread Neal Becker
Adam Hughes wrote: > If you are storing objects, then can't you store them in a list and just do: > > for obj in objectlist: > obj.attribute = value > > Or am I misunderstanding? > It's multi-dimensional, and I wanted to avoid writing explicit loops. _

Re: [Numpy-discussion] apply 'getitem to each element of obj array?

2012-04-05 Thread Adam Hughes
If you are storing objects, then can't you store them in a list and just do: for obj in objectlist: obj.attribute = value Or am I misunderstanding? On Thu, Apr 5, 2012 at 11:31 AM, Neal Becker wrote: > I have an array of object. > > How can I apply attribute access to each element? > > I

[Numpy-discussion] apply 'getitem to each element of obj array?

2012-04-05 Thread Neal Becker
I have an array of object. How can I apply attribute access to each element? I want to do, for example, np.all (u.some_attribute == 0) for all elements in u? ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/li

Re: [Numpy-discussion] small bug in ndarray.flatten()?

2012-04-05 Thread Chao YUE
nice to know this. can also use b.transpose().flatten() to circumvent it. thanks, Chao 2012/4/5 Pierre Haessig > Hi, > > Le 05/04/2012 15:00, Olivier Delalleau a écrit : > > Ok, it looks weird indeed. I was using numpy 1.6.1 myself, not sure if > > it's a bug that's been fixed in 1.6. > > Try

Re: [Numpy-discussion] MemoryError : with scipy.spatial.distance

2012-04-05 Thread Abhishek Pratap
Hi Gael The MemoryError exception I am getting is from using scikit's DBSCAN implementation. I can check mini-batch implementation of Kmeans. Best, -Abhi On Wed, Apr 4, 2012 at 10:33 PM, Gael Varoquaux wrote: > On Wed, Apr 04, 2012 at 04:41:51PM -0700, Abhishek Pratap wrote: >> Thanks Chris. So

Re: [Numpy-discussion] small bug in ndarray.flatten()?

2012-04-05 Thread Pierre Haessig
Hi, Le 05/04/2012 15:00, Olivier Delalleau a écrit : > Ok, it looks weird indeed. I was using numpy 1.6.1 myself, not sure if > it's a bug that's been fixed in 1.6. > Try without the keyword argument (b.flatten('C')), see if at least > that works. I can reproduce Chao's bug with my numpy 1.5. As

Re: [Numpy-discussion] small bug in ndarray.flatten()?

2012-04-05 Thread Olivier Delalleau
Ok, it looks weird indeed. I was using numpy 1.6.1 myself, not sure if it's a bug that's been fixed in 1.6. Try without the keyword argument (b.flatten('C')), see if at least that works. -=- Olivier Le 5 avril 2012 08:12, Chao YUE a écrit : > Hi, > > I use 1.51. > In [69]: np.__version__ > Out[

Re: [Numpy-discussion] small bug in ndarray.flatten()?

2012-04-05 Thread Chao YUE
Hi, I use 1.51. In [69]: np.__version__ Out[69]: '1.5.1' the help information seems OK. In [70]: b.flatten? Type:builtin_function_or_method Base Class: String Form: Namespace:Interactive Docstring: a.flatten(order='C') Return a copy of the array collapsed into one di

Re: [Numpy-discussion] small bug in ndarray.flatten()?

2012-04-05 Thread Olivier Delalleau
It works for me, which version of numpy are you using? What do you get when you type help(b.flatten)? -=- Olivier Le 5 avril 2012 04:45, Chao YUE a écrit : > Dear all, > > Is there a small bug in following? > > In [2]: b > Out[2]: > array([[ 0, 1, 2, 3, 4, 5], >[ 6, 7, 8, 9, 10,

[Numpy-discussion] small bug in ndarray.flatten()?

2012-04-05 Thread Chao YUE
Dear all, Is there a small bug in following? In [2]: b Out[2]: array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]]) In [3]: b.flatten(order='C') -