[Numpy-discussion] Resize method

2009-11-23 Thread Colin J. Williams
Access by the interpreter prevents array resizing. Yes, one can use the function, in place of the method but this appears to require copying the whole array. If one sets b= a, then that reference can be deleted with del b. Is there any similar technique for the interpreter? Colin W. Python

Re: [Numpy-discussion] Resize method

2009-11-23 Thread Colin J. Williams
Christopher Barker wrote: Colin J. Williams wrote: Access by the interpreter prevents array resizing. yup -- resize is really fragile for that reason. It really should be used quite sparingly. Personally, I think it should probably only be used when wrapped with a higher level layer.

Re: [Numpy-discussion] Resize method

2009-11-23 Thread Christopher Barker
Colin J. Williams wrote: Thanks for this. My aim is to extract a row of data from a line in a file and append it to an array. The number of columns is fixed but, at the start, the number of rows is unknown. That is exactly the kind of use-case I had in mind. In fact, you can use it now if

[Numpy-discussion] Resize Method for Numpy Array

2009-09-24 Thread Alice Invernizzi
Dear all, I have an Hamletic doubt concerning the numpy array data type. A general learned rule concerning the array usage in other high-level programming languages is that array data-type are homogeneous datasets of fixed dimension. Therefore, is not clear to me why in numpy the size of an

Re: [Numpy-discussion] Resize Method for Numpy Array

2009-09-24 Thread V. Armando Solé
Alice Invernizzi wrote: Dear all, I have an Hamletic doubt concerning the numpy array data type. A general learned rule concerning the array usage in other high-level programming languages is that array data-type are homogeneous datasets of fixed dimension. Therefore, is not clear to

Re: [Numpy-discussion] Resize Method for Numpy Array

2009-09-24 Thread V. Armando Solé
V. Armando Solé wrote: Sorry, there was a bug in the sent code. It should be: import numpy a=numpy.arange(100.) a.shape = 10, 10 b = a * 1 # just to get a copy b.shape = 5, 2, 5, 2 b = (b.sum(axis=3)).sum(axis=1) In that way, on b I have a binned image of a.

Re: [Numpy-discussion] Resize Method for Numpy Array

2009-09-24 Thread Christopher Barker
Alice Invernizzi wrote: Therefore, is not clear to me why in numpy the size of an array can be changed (either with the 'returning-value' resize() function either with the 'in-place' array method resize()). Would you please be so kind to give some explanation for the existence of resize

Re: [Numpy-discussion] Resize Method for Numpy Array

2009-09-24 Thread Robert Kern
On Thu, Sep 24, 2009 at 09:58, Alice Invernizzi inverni...@cilea.it wrote: Dear all, I have an Hamletic doubt concerning the numpy array data type. A general learned rule concerning the array usage in other high-level programming languages is that array data-type are homogeneous datasets of 

Re: [Numpy-discussion] Resize Method for Numpy Array

2009-09-24 Thread Sturla Molden
Robert Kern skrev: While this description is basically true of numpy arrays, I would caution you that every language has a different lexicon, and the same word can mean very different things in each. For example, Python lists are *not* linked lists; they are like C++'s std::vectors with a

Re: [Numpy-discussion] Resize Method for Numpy Array

2009-09-24 Thread Robert Kern
On Thu, Sep 24, 2009 at 17:32, Sturla Molden stu...@molden.no wrote: Robert Kern skrev: While this description is basically true of numpy arrays, I would caution you that every language has a different lexicon, and the same word can mean very different things in each. For example, Python lists

Re: [Numpy-discussion] Resize Method for Numpy Array

2009-09-24 Thread Sturla Molden
Robert Kern skrev: collections.deque() is a linked list of 64-item chunks. Thanks for that useful information. :-) But it would not help much for a binary tree... Since we are on the NumPy list... One could image making linked lists using NumPy arrays with dtype=object. They are storage