Re: [Numpy-discussion] Inverting argsort(a, axis=0) to obtain column-wise ranks

2010-09-09 Thread Alexander Michael
, September 9, 2010, Robert Kern wrote: > On Thu, Sep 9, 2010 at 15:59, Alexander Michael wrote: >> Clever and concise (and expect that it works), but isn't this less >> efficient? Sorting is O(n*log(n)), while the code I gave is O(n). >> Using argsort has the potential

[Numpy-discussion] Inverting argsort(a, axis=0) to obtain column-wise ranks

2010-09-09 Thread Alexander Michael
Clever and concise (and expect that it works), but isn't this less efficient? Sorting is O(n*log(n)), while the code I gave is O(n). Using argsort has the potential to use less memory, though. On Tuesday, September 7, 2010, Zachary Pincus wrote: >> indices = argsort(a1) >> ranks = zeros_like(indi

[Numpy-discussion] Inverting argsort(a, axis=0) to obtain column-wise ranks

2010-09-09 Thread Alexander Michael
Clever and concise (and expect that it works), but isn't this less efficient? Sorting is O(n*log(n)), while the code I gave is O(n). Using argsort has the potential to use less memory, though. On Tuesday, September 7, 2010, Zachary Pincus wrote: >> indices = argsort(a1) >> ranks = zeros_like(indi

[Numpy-discussion] Inverting argsort(a, axis=0) to obtain column-wise ranks

2010-09-07 Thread Alexander Michael
Calculating ranks by inverting the results of an argsort is straightforward and fast for 1D arrays: indices = argsort(a1) ranks = zeros_like(indices) ranks[indices] = arange(len(indices)) I was wondering if there was an equally pithy way to do this for multiple data samples stored column-wise in

[Numpy-discussion] Multi-Core Cache Usage Analyzer

2008-05-30 Thread Alexander Michael
An HPC friend altered me to a recent announcement of a new memory-optimization product. The article in HPCwire is here: and the company website is here: . Note sure of something like this would

Re: [Numpy-discussion] very simple iteration question.

2008-05-01 Thread Alexander Michael
On Wed, Apr 30, 2008 at 3:09 PM, Gael Varoquaux <[EMAIL PROTECTED]> wrote: > On Wed, Apr 30, 2008 at 11:57:44AM -0700, Christopher Barker wrote: > > I think I still like the idea of an iterator (or maybe making rollaxis a > > method?), but this works pretty well. > > Generally, in object oriente

Re: [Numpy-discussion] OSX installer: please test

2008-04-19 Thread Alexander Michael
On Wed, Apr 16, 2008 at 5:36 PM, Christopher Burns <[EMAIL PROTECTED]> wrote: > I've built a Universal Mac binary for numpy 1.1.0. If Mac people would > kindly test it, I'd appreciate any feedback. > > > Download here: > https://cirl.berkeley.edu/numpy/numpy-1.1.0rc1-py2.5-macosx10.5.dmg > > Techn

Re: [Numpy-discussion] Truth value of an array

2008-04-18 Thread Alexander Michael
On Fri, Apr 18, 2008 at 8:43 AM, Matthieu Brucher <[EMAIL PROTECTED]> wrote: > > > 2008/4/18, Olivier Verdier <[EMAIL PROTECTED]>: > > I certainly didn't mean that "A==B" should return a boolean!! > > > > "A==B" should return an array of boolean as it does now. This is all > right. > > > > *However

Re: [Numpy-discussion] Generically Creating Views of Equal Dimensions

2008-04-15 Thread Alexander Michael
On Tue, Apr 15, 2008 at 3:38 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > On Tue, Apr 15, 2008 at 9:54 AM, Alexander Michael <[EMAIL PROTECTED]> wrote: > > Is there an already existing method to create views that add as many > > dimensions as required to bring a colle

[Numpy-discussion] Generically Creating Views of Equal Dimensions

2008-04-15 Thread Alexander Michael
Is there an already existing method to create views that add as many dimensions as required to bring a collection of arrays to the same dimensionality by adding the appropriate number of numpy.newaxis's to the ends? For example: In [1]: a = numpy.array([1, 2, 3, 4]) In [2]: b = numpy.array([[1,10]

Re: [Numpy-discussion] Making NumPy accessible to everyone (or no-one) (was Numpy-discussion Digest, Vol 19, Issue 44)

2008-04-10 Thread Alexander Michael
On Thu, Apr 10, 2008 at 6:55 AM, Stéfan van der Walt <[EMAIL PROTECTED]> wrote: > Hi Joe, all > > On 10/04/2008, Joe Harrington <[EMAIL PROTECTED]> wrote: > > > Absolutely. Let's please standardize on: > > > import numpy as np > > > import scipy as sp > > > > I hope we do NOT standardize

Re: [Numpy-discussion] Simple financial functions for NumPy

2008-04-04 Thread Alexander Michael
On Fri, Apr 4, 2008 at 9:49 AM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > However, if clearly better interfaces can be discovered, then we could > change it. For now, the functions are not imported into the numpy > namespace but live in > > numpy.lib.financial > > I could see a future

Re: [Numpy-discussion] numpy's future (1.1 and beyond): which direction(s) ?

2008-03-22 Thread Alexander Michael
On Fri, Mar 21, 2008 at 12:35 AM, David Cournapeau <[EMAIL PROTECTED]> wrote: > numpy 1.0.5 is on the way, and I was wondering about numpy's future. I > myself have some ideas about what could be done; has there been any > discussion behind what is on 1.1 trac's roadmap ? MaskedArray, al

Re: [Numpy-discussion] how to build a series of arrays as I go?

2008-03-18 Thread Alexander Michael
On Tue, Mar 18, 2008 at 5:27 AM, Chris Withers <[EMAIL PROTECTED]> wrote: > Travis E. Oliphant wrote: > > Generally, arrays are not efficiently re-sized. It is best to > > pre-allocate, or simply create a list by appending and then convert to > > an array after the fact as you have done. > > T

Re: [Numpy-discussion] View ND Homogeneous Record Array as (N+1)D Array?

2008-03-18 Thread Alexander Michael
On Mon, Mar 17, 2008 at 4:55 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > On Mon, Mar 17, 2008 at 3:44 PM, Alexander Michael <[EMAIL PROTECTED]> wrote: > > Is there a way to view an N-dimensional array with a *homogeneous* > > record dtype as an array of N+1 dimensio

[Numpy-discussion] View ND Homogeneous Record Array as (N+1)D Array?

2008-03-17 Thread Alexander Michael
Is there a way to view an N-dimensional array with a *homogeneous* record dtype as an array of N+1 dimensions? An example will make it clear: import numpy a = numpy.array([(1.0,2.0), (3.0,4.0)], dtype=[('A',float),('B',float)]) b = a.view(...) # do something magical print b array([[ 1., 2.],

Re: [Numpy-discussion] Transforming an array of numbers to an array of formatted strings

2008-03-13 Thread Alexander Michael
On Thu, Mar 13, 2008 at 9:49 AM, Alan G Isaac <[EMAIL PROTECTED]> wrote: > And for 1d array ``x`` you can always do:: > >strdata = list( fmt%xi for xi in x) > > Nice because the counter name does not "bleed" into your program. On Thu, Mar 13, 2008 at 3:07 PM, David Huard <[EMAIL PROTECTED]> wr

[Numpy-discussion] Transforming an array of numbers to an array of formatted strings

2008-03-13 Thread Alexander Michael
Is there a better way than looping to perform the following transformation? >>> import numpy >>> int_data = numpy.arange(1,11, dtype=int) # just an example >>> str_data = int_data.astype('S4') >>> for i in xrange(len(int_data)): ... str_data[i] = 'S%03d' % int_data[i] >>> print str_data ['S00

Re: [Numpy-discussion] Generically Creating Intermediate Data Compatible with Either ndarray or MasledArray Types

2008-03-11 Thread Alexander Michael
On Tue, Mar 11, 2008 at 3:42 PM, Eric Firing <[EMAIL PROTECTED]> wrote: > I don't know if it works for older versions of numpy, but with svn you > can simply use the astype() method of the array. If the array is masked > it seems to work correctly, although it does not update the fill_value >

[Numpy-discussion] Generically Creating Intermediate Data Compatible with Either ndarray or MasledArray Types

2008-03-11 Thread Alexander Michael
I have a function that I would like to work with both MaskedArray's and ndarray's. The only blocker for this particular function is the need to create some stand-in data that is appropriately either a MaskedArray or an ndarray. Currently I have: dummy = numpy.ones(data.shape, dtype=bool) where da

Re: [Numpy-discussion] Trouble With MaskedArray and Shared Masks

2008-02-27 Thread Alexander Michael
On Tue, Feb 26, 2008 at 2:32 PM, Pierre GM <[EMAIL PROTECTED]> wrote: > Alexander, > The rationale behind the current behavior is to avoid an accidental > propagation of the mask. Consider the following example: > > >>>m = numpy.array([1,0,0,1,0], dtype=bool_) > >>>x = numpy.array([1,2,3,4,5])

[Numpy-discussion] Trouble With MaskedArray and Shared Masks

2008-02-26 Thread Alexander Michael
I'm having trouble with MaskedArray's _sharedmask flag. I would like to create a sub-view of a MaskedArray, fill it, and have the modifications reflected in the original array. This works with regular ndarrays, but only works with MaskedArrays if _sharedmask is set to False. Here's an example: >>>

Re: [Numpy-discussion] MaskedArray __setitem__ Performance

2008-02-16 Thread Alexander Michael
On Feb 16, 2008 3:21 PM, Pierre GM <[EMAIL PROTECTED]> wrote: > > Can I safely carry around the data, mask and MaskedArray? I'm > > considering working along the lines of the following conceptual > > outline: > > That depends a lot on what calculate_results does, and whether you update the > arrays

Re: [Numpy-discussion] MaskedArray __setitem__ Performance

2008-02-16 Thread Alexander Michael
On Feb 16, 2008 12:25 PM, Pierre GM <[EMAIL PROTECTED]> wrote: > Alexander, > You get the gist here: process your _data and _mask separately and recombine > them into a MaskedArray at the end. That way, you'll skip most of the > overhead costs brought by some tests in the package (in __getitem__, >

[Numpy-discussion] MaskedArray __setitem__ Performance

2008-02-15 Thread Alexander Michael
In part of some code I'm rewriting from carrying around a data and mask array to using MaskedArray, I read data into an array from an input stream. By its nature this a "one at a time" process, so it is basically a loop over assigning single elements (in no predetermined order) of already allocated

Re: [Numpy-discussion] MaskedArray __setitem__ for Record Values

2008-02-15 Thread Alexander Michael
On Fri, Feb 15, 2008 at 12:59 PM, Pierre GM <[EMAIL PROTECTED]> wrote: > Good call. > The easiest is still to replace the line 1361 with: > dval = narray(value, copy=False, dtype=self.dtype) > > The problem with the initial method was that the tuple got transformed into a > (2,) array whose ty

Re: [Numpy-discussion] List Array References?

2008-02-15 Thread Alexander Michael
On Fri, Feb 15, 2008 at 11:51 AM, Stefan van der Walt <[EMAIL PROTECTED]> wrote: > Numpy does complain if you attempt to resize an array with views on > it: > > In [8]: x = np.array([1,2,3]) > > In [14]: y = x[::-1] > > In [18]: x.resize((4,)) > ---

[Numpy-discussion] MaskedArray __setitem__ for Record Values

2008-02-15 Thread Alexander Michael
I am attempting to work with field dtypes (i.e. record arrays) as MaskedArrays. I don't want to use MaskedRecords because I want the mask to apply to the whole record since the first field is primary and the rest are "tag along" values associated with the primary data value. The numpy.ndarray suppo

Re: [Numpy-discussion] List Array References?

2008-02-15 Thread Alexander Michael
On Fri, Feb 15, 2008 at 7:12 AM, Stefan van der Walt <[EMAIL PROTECTED]> wrote: > As far as I know, the reference count to the array is increased when > you create a view, but the views themselves are not tracked anywhere. > You can therefore say whether there are references around, but you > c

[Numpy-discussion] List Array References?

2008-02-14 Thread Alexander Michael
Is there a way to list all of the arrays that are referencing a given array? Similarly, is there a way to get a list of all arrays that are currently in memory? Thanks, Alex ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.sci

Re: [Numpy-discussion] An idea for future numpy windows installers

2008-02-04 Thread Alexander Michael
On Feb 4, 2008 5:13 AM, David Cournapeau <[EMAIL PROTECTED]> wrote: > Hi, > > While studying a bit nsis (an open source system to build windows > installers), I realized that it would be good if we could detect the > target CPU and install the right numpy accordingly. I have coded a > nsis plugin

Re: [Numpy-discussion] Median again

2008-01-29 Thread Alexander Michael
On Jan 29, 2008, at 11:51 AM, Joris De Ridder wrote: > This feature request has been repeatedly asked before (e.g. 6 months > ago). The relevant ticket (#558, although this only asks for axis > support) mentions a milestone 1.1. I would like to ask if it could be > moved somewhat higher on the prio

Re: [Numpy-discussion] MaskedArray and the min, max, sum, prod Methods

2008-01-04 Thread Alexander Michael
On Jan 4, 2008 10:42 AM, Pierre GM <[EMAIL PROTECTED]> wrote: > On Friday 04 January 2008 10:27:32 Alexander Michael wrote: > > > Hmm. I liked the base ndarray behavior as it makes a lot of sense to > > me and provides an easy default that avoids needing to check the

Re: [Numpy-discussion] MaskedArray and the min, max, sum, prod Methods

2008-01-04 Thread Alexander Michael
On Jan 4, 2008 10:01 AM, Pierre GM <[EMAIL PROTECTED]> wrote: > On Thursday 03 January 2008 15:49:45 Alexander Michael wrote: > > Working with the new MaskedArray, I noticed the following differences > > > > with numpy.array behavior: > > >>&

[Numpy-discussion] MaskedArray and the min,max,sum,prod Methods

2008-01-03 Thread Alexander Michael
Working with the new MaskedArray, I noticed the following differences with numpy.array behavior: >>> masked_array([1, 2, 3], mask=True).min() 2147483647 >>> array([]).min() Traceback (most recent call last): File "", line 1, in ValueError: zero-size array to ufunc.reduce without identity >>> m

[Numpy-discussion] MaskedArray and Record Arrays

2008-01-03 Thread Alexander Michael
I am experimenting with the new MaskedArray (from ) as a replacement for my own home-brewed masked data handling mechanisms. In what I have built myself, I often work with record arrays that have a single mask for the whole record (no fieldmask).

Re: [Numpy-discussion] Changing the distributed binary for numpy 1.0.4 for windows ?

2007-12-10 Thread Alexander Michael
On Dec 10, 2007 6:48 AM, David Cournapeau <[EMAIL PROTECTED]> wrote: > Hi, > > Several people reported problems with numpy 1.0.4 (See #627 and > #628, but also other problems mentionned on the ML, which I cannot > find). They were all solved, as far as I know, by a binary I produced > (simply u

Re: [Numpy-discussion] numpy 1.04 numpy.test() hang

2007-11-10 Thread Alexander Michael
On 11/9/07, Geoffrey Zhu <[EMAIL PROTECTED]> wrote: > And then I downloaded the egg file and ran easy_install > c:\mypath\numpy-1.0.4-py2.5-win32.egg. Do not put the egg file in any > of your python package directories, or easy_install won't unpack it. I > haven't figured out why. Most likely beca

Re: [Numpy-discussion] Maskedarray implementations

2007-08-25 Thread Alexander Michael
Is there any documentation available for your maskedarray? I would like to get a feel for the basics, like how do I take the dot product, do elementwise multiplication, etc, with your implementation. Thanks, Alex ___ Numpy-discussion mailing list Numpy-d

Re: [Numpy-discussion] SciPy Journal

2007-06-04 Thread Alexander Michael
On 5/31/07, Travis Oliphant <[EMAIL PROTECTED]> wrote: > Hi everybody, > > I'm sorry for the cross posting, but I wanted to reach a wide audience > and I know not everybody subscribes to all the lists. > > I've been thinking more about the "SciPy Journal" that we discussed > before and I have some

Re: [Numpy-discussion] Array of Arrays

2007-03-23 Thread Alexander Michael
On 3/23/07, Sebastian Haase <[EMAIL PROTECTED]> wrote: > Hold on -- aren't the "..." at the *end* always implicit: > I you have > a.shape = (6,5,4,3) > a[3,2] is the same as a[3,2,:,:] is the same as a[3,2,...] > > only if you wanted a[...,3,2] you would have to change your code !? > Am I confus

Re: [Numpy-discussion] Array of Arrays

2007-03-23 Thread Alexander Michael
On 3/23/07, Nadav Horesh <[EMAIL PROTECTED]> wrote: > How about > > a = empty((5,7,4)) > c = a[...,-1] Solely because I want to use the array with code that assumes it is working with two-dimensional arrays but yet only performs operations on the "outer" two-dimensional array that would be consi

[Numpy-discussion] Array of Arrays

2007-03-23 Thread Alexander Michael
How can I do something like the following? a = empty((5,7), dtype=<4 element array of floats>) c = a[:,-1] # last column of 4 element arrays a[0,0] = 2.0 print a[0,0] [2. 2. 2. 2.] a[1,0] = 3.0 a[0,1] = a[0,0] * a[1,0] print a[0,1] [6. 6. 6. 6.] etc. As always, thanks for the help! Alex

Re: [Numpy-discussion] Matlab -> NumPy translation and indexing

2007-03-20 Thread Alexander Michael
On 3/20/07, David Koch <[EMAIL PROTECTED]> wrote: > And by the way - whenever I do a .__doc__ all newline characters > are printed as "\n" in the python console ... how do I change that? The easiest way to access the doc strings is to type help() in the python interpreter, or ? in ipython (). The

[Numpy-discussion] Multiplying Each Column of a Matrix by a Vector (Element-Wise)

2007-03-14 Thread Alexander Michael
Is there a clever way to multiply each column of a matrix by a vector *element-wise*? That is, the equivalent of (from some 1D v and 2D m): r = numpy.empty_like(m) for i in range(m.shape[-1]): r[...,i] = v*m[...,i] Thanks, Alex ___ Numpy-discussion

Re: [Numpy-discussion] Managing Rolling Data

2007-02-23 Thread Alexander Michael
Timothy's refinement of Anne's idea will work for me: >>> import timeit >>> print '%.2fms/push' % (1000 * timeit.Timer( ..."a[...,:-1] = a[...,1:]", ..."from numpy import empty; a = empty((5000,20,1000))" ...).timeit(number=10)/10) 537.86ms/push I still find the ring buffer solution

Re: [Numpy-discussion] Managing Rolling Data

2007-02-22 Thread Alexander Michael
On 2/22/07, Sturla Molden <[EMAIL PROTECTED]> wrote: > A ring buffer is O(1) whereas a memmove is O(N). Unless the amount of > data to be moved are very small, this makes the ringbuffer the more > attractive solution. > > Slicing becomes a little bit more complicated with a ring, but not very > muc

Re: [Numpy-discussion] Managing Rolling Data

2007-02-21 Thread Alexander Michael
On 2/21/07, Mike Ressler <[EMAIL PROTECTED]> wrote: > Would loading your data via memmap, then slicing it, do your job > (using numpy.memmap)? ... Interesting idea. I think Anne's suggestion that sliced assignment will reduce to an efficient memcpy fits my needs a bit better than memmap because I'

Re: [Numpy-discussion] Managing Rolling Data

2007-02-21 Thread Alexander Michael
On 2/21/07, Mike Ressler <[EMAIL PROTECTED]> wrote: > Would loading your data via memmap, then slicing it, do your job > (using numpy.memmap)? ... Interesting idea. I think Anne's suggestion that sliced assignment will reduce to an efficient memcpy fits my needs a bit better than memmap because I'

[Numpy-discussion] Managing Rolling Data

2007-02-21 Thread Alexander Michael
I'm new to numpy and looking for advice on setting up and managing array data for my particular problem. I'm collecting observations of P properties for N objects over a rolling horizon of H sample times. I could conceptually store the data in three-dimensional array with shape (N,P,H) that would a