[Numpy-discussion] repeat array along new axis without making a copy

2012-02-15 Thread Steve Schmerler
Hi I'd like to repeat an array along a new axis (like broadcast): In [8]: a Out[8]: array([[0, 1, 2], [3, 4, 5]]) In [9]: b=repeat(a[None,...], 3, axis=0) In [10]: b Out[10]: array([[[0, 1, 2], [3, 4, 5]], [[0, 1, 2],

Re: [Numpy-discussion] repeat array along new axis without making a copy

2012-02-15 Thread Steve Schmerler
On Feb 15 06:25 -0600, Warren Weckesser wrote: Yes, such an array can be created using the as_strided() function from the module numpy.lib.stride_tricks: Thank you, I will look into that. best, Steve ___ NumPy-Discussion mailing list

[Numpy-discussion] subtle behavior when subtracting sub-arrays

2010-07-05 Thread Steve Schmerler
Hi I stumbled upon some numpy behavior which I was not aware of. Say I have an array of shape (2,2,3) and want to subtract the sub-array a[...,0] of shape (2,2) from each a[...,i], i=0,1,2 . ## ok ## In [1]: a=arange(2*2*3).reshape(2,2,3) # Copy the array to be subtracted. In

[Numpy-discussion] subclassing ndarray

2008-12-05 Thread Steve Schmerler
Hi all I'm subclassing ndarray following [1] and I'd like to know if i'm doing it right. My goals are - ndarray subclass MyArray with additional methods - replacement for np.array, np.asarray on module level returning MyArray instances - expose new methods as functions on module level

Re: [Numpy-discussion] numpy array change notifier?

2008-10-30 Thread Steve Schmerler
On Oct 27 16:43 -0400, Pierre GM wrote: Erik, may be you could try the trick presented here : http://www.scipy.org/Subclasses in the __array_wrap__ section. Stupid question: How do I find pages like http://www.scipy.org/Subclasses on scipy.org? I can find them with the search function,

Re: [Numpy-discussion] numpy array change notifier?

2008-10-30 Thread Steve Schmerler
On Oct 30 10:06 -0400, Pierre GM wrote: Steve, Right, there's not a lot of visibility for this one. Yes, wouldn't it be better placed in the Cookbook section (or any other suitable place that's visible to anyone entering scipy.org)? Other pages are unfortunately also not visible, like

Re: [Numpy-discussion] how to save a large array into a file quickly

2008-10-15 Thread Steve Schmerler
On Oct 14 15:29 -1000, Eric Firing wrote: frank wang wrote: Hi, I have a large ndarray that I want to dump to a file. I know that I can use a for loop to write one data at a time. Since Python is a very powerfully language, I want to find a way that will dump the data fast and