Re: [Numpy-discussion] Iterate over all 1-dim views

2007-10-08 Thread Stefan van der Walt
On Sun, Oct 07, 2007 at 06:52:11AM -0400, Neal Becker wrote: Suppose I have a function F(), which is defined for 1-dim arguments. If the user passes an n1 dim array, I want to apply F to each 1-dim view. For example, for a 2-d array, apply F to each row and return a 2-d result. For a 3-d

[Numpy-discussion] dot product not behaving as expected

2007-10-08 Thread Robin
Hi, I have a problem using numpy.dot, see below: In [151]: m=5 In [152]: n=5 In [153]: x=(m*ones((1,5)))**arange(0,n) In [154]: y=test.order_length[::-1] In [155]: x Out[155]: array([[ 1.,5., 25., 125., 625.]]) In [156]: y Out[156]: array([[ 1024.], [ 1280.], [

Re: [Numpy-discussion] dot product not behaving as expected

2007-10-08 Thread Robert Kern
Robin wrote: Hi, I have a problem using numpy.dot, see below: In [151]: m=5 In [152]: n=5 In [153]: x=(m*ones((1,5)))**arange(0,n) In [154]: y=test.order_length[::-1] In [155]: x Out[155]: array([[ 1.,5., 25., 125., 625.]]) In [156]: y Out[156]: array([[ 1024.],

Re: [Numpy-discussion] dot product not behaving as expected

2007-10-08 Thread Robin
It works for me with a recent SVN numpy on OS X. What version of numpy are you using? What platform are you on? Did you build with ATLAS or other optimized linear algebra library? I am on Ubuntu 7.04, gcc 4.1.2 In [181]: numpy.__version__ Out[181]: '1.0.4.dev4155' Built with ATLAS

Re: [Numpy-discussion] dot product not behaving as expected

2007-10-08 Thread Robert Kern
Robin wrote: It works for me with a recent SVN numpy on OS X. What version of numpy are you using? What platform are you on? Did you build with ATLAS or other optimized linear algebra library? I am on Ubuntu 7.04, gcc 4.1.2 In [181]: numpy.__version__ Out[181]:

Re: [Numpy-discussion] Convert array type

2007-10-08 Thread Ryan May
Gary Ruben wrote: Try using astype. This works: values = array(wavearray.split()).astype(float) Why not use numpy.fromstring? fromstring(string, dtype=float, count=-1, sep='') Return a new 1d array initialized from the raw binary data in string. If count is positive, the new

[Numpy-discussion] numpy/Windows shared arrays between processes?

2007-10-08 Thread Ray S
Is anyone sharing arrays between processes on Windows? I tried compiling the posh sources (once, so far) with the new MS toolkit and failed... What other solutions are in use? Have a second process create an array view from an address would suffice for this particular purpose. I could pass the

Re: [Numpy-discussion] Convert array type

2007-10-08 Thread Adam Mercer
On 08/10/2007, Ryan May [EMAIL PROTECTED] wrote: Why not use numpy.fromstring? because that results in the array being filled with gibberish values = numpy.fromstring(wavearray, dtype=float, count=-1, sep='') print values gives: [ 1.39804329e-076 1.30354290e-076 1.18295070e-076 ...,

Re: [Numpy-discussion] Convert array type

2007-10-08 Thread Robert Kern
Adam Mercer wrote: On 08/10/2007, Ryan May [EMAIL PROTECTED] wrote: Why not use numpy.fromstring? because that results in the array being filled with gibberish values = numpy.fromstring(wavearray, dtype=float, count=-1, sep='') Use sep=' '. As the docstring says, if sep is empty, then

Re: [Numpy-discussion] Convert array type

2007-10-08 Thread Charles R Harris
On 10/8/07, Adam Mercer [EMAIL PROTECTED] wrote: On 08/10/2007, Ryan May [EMAIL PROTECTED] wrote: Why not use numpy.fromstring? because that results in the array being filled with gibberish values = numpy.fromstring(wavearray, dtype=float, count=-1, sep='') print values You need to use

Re: [Numpy-discussion] beginner question: rank-1 arrays

2007-10-08 Thread Gael Varoquaux
On Mon, Oct 08, 2007 at 11:00:39PM +0100, Robin wrote: Coming from matlab and being use to 0:10 for row or (0:10)' for column this seems a bit messy. Is there a better way of constructing row/column 2d arrays from a slice type range? r_[0:10] and c_[0:10]. Does that suit you ? The

Re: [Numpy-discussion] beginner question: rank-1 arrays

2007-10-08 Thread Stefan van der Walt
On Mon, Oct 08, 2007 at 11:00:39PM +0100, Robin wrote: Hi, I am trying to implement a project in scipy. I think I am getting somewhere finally. However in my code (I am converting from MATLAB) it is important to maintain 2d arrays, and keep the difference between row and column vectors.

Re: [Numpy-discussion] beginner question: rank-1 arrays

2007-10-08 Thread Gael Varoquaux
On Mon, Oct 08, 2007 at 11:12:07PM +0100, Robin wrote: On 10/8/07, Gael Varoquaux [EMAIL PROTECTED] wrote: r_[0:10] and c_[0:10]. Does that suit you ? The first one is indeed only 1D, but I don't see the problem with that. If you really want 2D you can use c_[0:10].T

Re: [Numpy-discussion] beginner question: rank-1 arrays

2007-10-08 Thread Alan G Isaac
On Mon, 8 Oct 2007, Robin apparently wrote: However in my code (I am converting from MATLAB) it is important to maintain 2d arrays, and keep the difference between row and column vectors. How about using matrices? help(numpy.mat) hth, Alan Isaac

Re: [Numpy-discussion] beginner question: rank-1 arrays

2007-10-08 Thread Robin
On 10/8/07, Gael Varoquaux [EMAIL PROTECTED] wrote: Damn it. Shame on me. I meant c_[0:10,]. If you really need a shape of (1,10) (I have never had such a need) you can use c_[0:10,].T. Thanks! - the trick with the , is just the sort of thing I was looking for - I knew there must be an easy

Re: [Numpy-discussion] Convert array type

2007-10-08 Thread Adam Mercer
On 08/10/2007, Robert Kern [EMAIL PROTECTED] wrote: Use sep=' '. As the docstring says, if sep is empty, then the string is interpreted as binary data. If it is not empty, then the string is interpreted as ASCII. Thanks, got it the wrong way round. That works now. Cheers Adam