Re: [Numpy-discussion] Building on WinXP 64-bit, Intel Compilers

2009-01-30 Thread Hanni Ali
I have been meaning to chip in but so far hadn't got to it so hear goes. In response to this particular issue I currently use numpy (1.2.1) built with msvc VS 2008 by simply commenting out these definitions in the numpy\core\src\umathmodule.c.src That works just fine and allows me to use the

[Numpy-discussion] minor improvment to ones

2009-01-30 Thread Neal Becker
A nit, but it would be nice if 'ones' could fill with a value other than 1. Maybe an optional val= keyword? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread David Cournapeau
Neal Becker wrote: A nit, but it would be nice if 'ones' could fill with a value other than 1. Maybe an optional val= keyword? What would be the advantage compared to fill ? I would guess ones and zeros are special because those two values are special (they can be defined for many types,

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Scott Sinclair
2009/1/30 David Cournapeau da...@ar.media.kyoto-u.ac.jp: Neal Becker wrote: A nit, but it would be nice if 'ones' could fill with a value other than 1. Maybe an optional val= keyword? What would be the advantage compared to fill ? I would guess ones and zeros are special because those two

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Grissiom
On Fri, Jan 30, 2009 at 21:54, Scott Sinclair scott.sinclair...@gmail.comwrote: 2009/1/30 David Cournapeau da...@ar.media.kyoto-u.ac.jp: Neal Becker wrote: A nit, but it would be nice if 'ones' could fill with a value other than 1. Maybe an optional val= keyword? What would be the

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Sturla Molden
On 1/30/2009 2:18 PM, Neal Becker wrote: A nit, but it would be nice if 'ones' could fill with a value other than 1. Maybe an optional val= keyword? I am -1 on this. Ones should fill with ones, zeros should fill with zeros. Anything else is counter-intuitive. Calling numpy.ones to fill

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Matthieu Brucher
Is fill function has any advantage over ones(size)*x ? No intermediate array (inplace) ? Matthieu -- Information System Engineer, Ph.D. Website: http://matthieu-brucher.developpez.com/ Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn:

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Sturla Molden
On 1/30/2009 3:07 PM, Grissiom wrote: Is fill function has any advantage over ones(size)*x ? You avoid filling with ones, all the multiplications and creating an temporary array. It can be done like this: a = empty(size) a[:] = x Which would be slightly faster and more memory efficient.

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Neal Becker
Right now there are 2 options to create an array of constant value: 1) empty (size); fill (val) 2) ones (size) * val 1 has disadvantage of not being an expression, so can't be an arg to a function call. Also probably slower than create+fill @ same time 2 is probably slower than create+fill @

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Grissiom
On Fri, Jan 30, 2009 at 22:16, Sturla Molden stu...@molden.no wrote: On 1/30/2009 3:07 PM, Grissiom wrote: Is fill function has any advantage over ones(size)*x ? You avoid filling with ones, all the multiplications and creating an temporary array. It can be done like this: a =

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Ryan May
Sturla Molden wrote: On 1/30/2009 2:18 PM, Neal Becker wrote: A nit, but it would be nice if 'ones' could fill with a value other than 1. Maybe an optional val= keyword? I am -1 on this. Ones should fill with ones, zeros should fill with zeros. Anything else is counter-intuitive. Calling

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Sturla Molden
On 1/30/2009 3:22 PM, Neal Becker wrote: Now what would be _really_ cool is a special array type that would represent a constant array without wasting memory. Which again is a special case of something even cooler: lazy evaluation. This would require arrays to have immutable buffers. Then an

[Numpy-discussion] example reading binary Fortran file

2009-01-30 Thread David Froger
Hy, My question is about reading Fortran binary file (oh no this question again...) Until now, I was using the unpack module like that : def lread(f,fourBeginning,fourEnd,*tuple): from struct import unpack Reading a Fortran binary file in litte-endian if fourBeginning: f.seek(4,1)

Re: [Numpy-discussion] example reading binary Fortran file

2009-01-30 Thread Sturla Molden
On 1/30/2009 5:03 PM, David Froger wrote: I think it will be a good idea to put the Fortran writting-arrays code and the Python reading-array script in the cookbook and maybe a page to help people comming from Fortran to start with Python ? If you want to be completely safe, read the file

[Numpy-discussion] concatenate trouble

2009-01-30 Thread Neal Becker
What's the problem here? print np.concatenate (np.ones (10, dtype=complex), np.zeros (10, dtype=complex)) TypeError: only length-1 arrays can be converted to Python scalars ___ Numpy-discussion mailing list Numpy-discussion@scipy.org

Re: [Numpy-discussion] example reading binary Fortran file

2009-01-30 Thread Sturla Molden
On 1/30/2009 5:23 PM, Sturla Molden wrote: ux = np.fromfile(nx*ny, dtype=np.float32).view((nx,ny), order='F') oops.. this should be ux = np.fromfile(file, count=nx*ny, dtype=np.float32).view((nx,ny), order='F') S.M. ___ Numpy-discussion

Re: [Numpy-discussion] concatenate trouble

2009-01-30 Thread Robert Cimrman
Neal Becker wrote: What's the problem here? print np.concatenate (np.ones (10, dtype=complex), np.zeros (10, dtype=complex)) TypeError: only length-1 arrays can be converted to Python scalars You should enclose the arrays you concatenate into a tuple: np.concatenate((a,b)). r.

Re: [Numpy-discussion] example reading binary Fortran file

2009-01-30 Thread Sturla Molden
On 1/30/2009 5:27 PM, Sturla Molden wrote: On 1/30/2009 5:23 PM, Sturla Molden wrote: ux = np.fromfile(nx*ny, dtype=np.float32).view((nx,ny), order='F') oops.. this should be ux = np.fromfile(file, count=nx*ny, dtype=np.float32).view((nx,ny), order='F') fu*k ux =

[Numpy-discussion] Data file format choice.

2009-01-30 Thread Gary Pajer
It's time for me to select a data format. My data are (more or less) spectra ( a couple of thousand samples), six channels, each channel running around 10 Hz, collecting for a minute or so. Plus all the settings on the instrument. I don't see any significant differences between netCDF4 and HDF5.

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Christopher Barker
On 1/30/2009 3:22 PM, Neal Becker wrote: Now what would be _really_ cool is a special array type that would represent a constant array without wasting memory. Can't you do that with scary stride tricks? I think I remember some discussion of this a while back. -Chris -- Christopher

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Ryan May
Christopher Barker wrote: On 1/30/2009 3:22 PM, Neal Becker wrote: Now what would be _really_ cool is a special array type that would represent a constant array without wasting memory. Can't you do that with scary stride tricks? I think I remember some discussion of this a while back.

Re: [Numpy-discussion] example reading binary Fortran file

2009-01-30 Thread Christopher Barker
If you want to be completely safe, read the file in Fortran, then send it as an array to Python (use f2py). Aside from that, assuming your compiler only writes the raw bytes in Fortran order to the file: Careful -- the last time I read a Fortran-=written binary file, I found that the

[Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Raik Gruenberg
Hi there, perhaps someone has a bright idea for this one: I want to concatenate ranges of numbers into a single array (for indexing). So I have generated an array a with starting positions, for example: a = [4, 0, 11] I have an array b with stop positions: b = [11, 4, 15] and I would like to

Re: [Numpy-discussion] example reading binary Fortran file

2009-01-30 Thread David Froger
Thank Sturla and Christopher, yes, with the Fortran code : != program makeArray implicit none integer,parameter:: nx=2,ny=5 real(4),dimension(nx,ny):: ux,uy,p integer :: i,j open(11,file='uxuyp.bin',form='unformatted') do i = 1,nx do j = 1,ny

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Jim Vickroy
Raik Gruenberg wrote: Hi there, perhaps someone has a bright idea for this one: I want to concatenate ranges of numbers into a single array (for indexing). So I have generated an array a with starting positions, for example: a = [4, 0, 11] I have an array b with stop positions: b =

[Numpy-discussion] using numpy functions on an array of objects

2009-01-30 Thread Sebastian Walter
Hey, What is the best solution to get this code working? Anyone a good idea? -- test.py --- import numpy import numpy.linalg class afloat: def __init__(self,x): self.x = x def __add__(self,rhs):

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Raik Gruenberg
Jim Vickroy wrote: Raik Gruenberg wrote: Hi there, perhaps someone has a bright idea for this one: I want to concatenate ranges of numbers into a single array (for indexing). So I have generated an array a with starting positions, for example: a = [4, 0, 11] I have an array b with

Re: [Numpy-discussion] example reading binary Fortran file

2009-01-30 Thread Ryan May
David Froger wrote: import numpy as np nx,ny = 2,5 fourBytes = np.fromfile('uxuyp.bin', count=1, dtype=np.float32) ux = np.fromfile('uxuyp.bin', count=nx*ny, dtype=np.float32).reshape((nx,ny), order='F') print ux #=== I get : [[

Re: [Numpy-discussion] Data file format choice.

2009-01-30 Thread Jeff Whitaker
Gary Pajer wrote: It's time for me to select a data format. My data are (more or less) spectra ( a couple of thousand samples), six channels, each channel running around 10 Hz, collecting for a minute or so. Plus all the settings on the instrument. I don't see any significant differences

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Jim Vickroy
Raik Gruenberg wrote: Jim Vickroy wrote: Raik Gruenberg wrote: Hi there, perhaps someone has a bright idea for this one: I want to concatenate ranges of numbers into a single array (for indexing). So I have generated an array a with starting positions, for example: a = [4, 0, 11] I

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Pierre GM
On Jan 30, 2009, at 1:11 PM, Raik Gruenberg wrote: Mhm, I got this far. But how do I get from here to a single index array [ 4, 5, 6, ... 10, 0, 1, 2, 3, 11, 12, 13, 14 ] ? np.concatenate([np.arange(aa,bb) for (aa,bb) in zip(a,b)]) ___

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Raik Gruenberg
Pierre GM wrote: On Jan 30, 2009, at 1:11 PM, Raik Gruenberg wrote: Mhm, I got this far. But how do I get from here to a single index array [ 4, 5, 6, ... 10, 0, 1, 2, 3, 11, 12, 13, 14 ] ? np.concatenate([np.arange(aa,bb) for (aa,bb) in zip(a,b)]) exactly! Now, the question was, is

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-30 Thread frank wang
I have created a test example for the question using for loop and hope someone can help me to get fast solution. My data set is about 200 data. However, I have the problem to run the code, the Out[i]=cnstl[j] line gives me error says: In [107]:

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Pierre GM
On Jan 30, 2009, at 1:53 PM, Raik Gruenberg wrote: Pierre GM wrote: On Jan 30, 2009, at 1:11 PM, Raik Gruenberg wrote: Mhm, I got this far. But how do I get from here to a single index array [ 4, 5, 6, ... 10, 0, 1, 2, 3, 11, 12, 13, 14 ] ? np.concatenate([np.arange(aa,bb) for (aa,bb)

Re: [Numpy-discussion] using numpy functions on an array of objects

2009-01-30 Thread Christopher Barker
I think you want to subclass an ndarray here. It's a bit tricky to so, but if you look in the wiki and these mailing list archives, you'll find advise on how to do it. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959

Re: [Numpy-discussion] Data file format choice.

2009-01-30 Thread Francesc Alted
A Friday 30 January 2009, Jeff Whitaker escrigué: Gary Pajer wrote: It's time for me to select a data format. My data are (more or less) spectra ( a couple of thousand samples), six channels, each channel running around 10 Hz, collecting for a minute or so. Plus all the settings on the

Re: [Numpy-discussion] example reading binary Fortran file

2009-01-30 Thread Sturla Molden
Careful -- the last time I read a Fortran-=written binary file, I found that the various structures (is that what you call them in Fortran?) were padded with I think 4 bytes. That is precisely why I suggested using f2py. If you let Fortran read the file (be careful to the same compiler!), it

[Numpy-discussion] NumPy distutils limitation?

2009-01-30 Thread Francesc Alted
Hi, Gregor and I are trying to give support for Intel's VML (Vector Mathematical Library) in numexpr. For this, we are trying to make use of the weaponery in NumPy's distutils so as to be able to discover where the MKL (the package that contains VML) is located. The libraries that we need to

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 11:26, Ryan May rma...@gmail.com wrote: Christopher Barker wrote: On 1/30/2009 3:22 PM, Neal Becker wrote: Now what would be _really_ cool is a special array type that would represent a constant array without wasting memory. Can't you do that with scary stride

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 08:22, Neal Becker ndbeck...@gmail.com wrote: Right now there are 2 options to create an array of constant value: 1) empty (size); fill (val) 2) ones (size) * val 1 has disadvantage of not being an expression, so can't be an arg to a function call. So wrap it in a

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 12:58, frank wang f...@hotmail.com wrote: I have created a test example for the question using for loop and hope someone can help me to get fast solution. My data set is about 200 data. However, I have the problem to run the code, the Out[i]=cnstl[j] line gives me

Re: [Numpy-discussion] using numpy functions on an array of objects

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 13:18, Christopher Barker chris.bar...@noaa.gov wrote: I think you want to subclass an ndarray here. It's a bit tricky to so, but if you look in the wiki and these mailing list archives, you'll find advise on how to do it. That still won't work. numpy.linalg.inv()

Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Rick White
Here's a technique that works: Python 2.4.2 (#5, Nov 21 2005, 23:08:11) [GCC 4.0.0 20041026 (Apple Computer, Inc. build 4061)] on darwin Type help, copyright, credits or license for more information. import numpy as np a = np.array([0,4,0,11]) b = np.array([-1,11,4,15]) rangelen = b-a+1

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Neal Becker
Robert Kern wrote: On Fri, Jan 30, 2009 at 08:22, Neal Becker ndbeck...@gmail.com wrote: Right now there are 2 options to create an array of constant value: 1) empty (size); fill (val) 2) ones (size) * val 1 has disadvantage of not being an expression, so can't be an arg to a function

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 16:32, Neal Becker ndbeck...@gmail.com wrote: Robert Kern wrote: On Fri, Jan 30, 2009 at 08:22, Neal Becker ndbeck...@gmail.com wrote: Right now there are 2 options to create an array of constant value: 1) empty (size); fill (val) 2) ones (size) * val 1 has

Re: [Numpy-discussion] example reading binary Fortran file

2009-01-30 Thread David Froger
ok for f2py! Otherwise, you will have to figure out how your Fortran program writes the file. I.e. what padding, metainformation, etc. that are used. If you switch Fortran compiler, or even compiler version from the same vendor, you must start over again. In my experience, I never had this kind

[Numpy-discussion] numpy.distutils and shared libraries

2009-01-30 Thread Brian Granger
Hi, 2 ?'s about numpy.distutils: 1. I am using config.add_library to build a c++ library that I will link into some Cython extensions. This is working fine and generating a .a library for me. However, I need a shared library instead. Is this possible with numpy.distutils or will I need

Re: [Numpy-discussion] numpy.distutils and shared libraries

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 18:13, Brian Granger ellisonbg@gmail.com wrote: Hi, 2 ?'s about numpy.distutils: 1. I am using config.add_library to build a c++ library that I will link into some Cython extensions. This is working fine and generating a .a library for me. However, I need a

Re: [Numpy-discussion] numpy.distutils and shared libraries

2009-01-30 Thread Brian Granger
I am using config.add_library to build a c++ library that I will link into some Cython extensions. This is working fine and generating a .a library for me. However, I need a shared library instead. Is this possible with numpy.distutils or will I need something like numscons? numscons or

Re: [Numpy-discussion] NumPy distutils limitation?

2009-01-30 Thread David Cournapeau
On Sat, Jan 31, 2009 at 5:30 AM, Francesc Alted fal...@pytables.org wrote: Hi, Gregor and I are trying to give support for Intel's VML (Vector Mathematical Library) in numexpr. For this, we are trying to make use of the weaponery in NumPy's distutils so as to be able to discover where the

Re: [Numpy-discussion] example reading binary Fortran file

2009-01-30 Thread Gary Ruben
The only time I've done this, I used numpy.fromfile exactly as follows. The file had a header followed by a number of records (one float followed by 128 complex numbers), requiring separate calls of numpy.fromfile to read each part. The only strange part about this was that the Fortran code

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 22:41, frank wang f...@hotmail.com wrote: Thanks for the correction. I will learn the ravel() function since I do not know it. Moving from Matlab world into python is tricky sometime. Your output In [22]: out Out[22]: array([ 1.+3.j, -5.+9.j]) In [23]: error

Re: [Numpy-discussion] help on fast slicing on a grid

2009-01-30 Thread frank wang
Hi, Bob, Thanks. This solution works great. It really helps me a lot. Frank Date: Fri, 30 Jan 2009 23:08:35 -0600 From: robert.k...@gmail.com To: numpy-discussion@scipy.org Subject: Re: [Numpy-discussion] help on fast slicing on a grid On Fri, Jan 30, 2009 at 22:41, frank wang