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
wrot
On Fri, Jan 30, 2009 at 22:41, frank wang 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
>> Out[23]: a
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> Out[23]:
array([ 0.4-0.3j, 0.1-0.7j])
are correct answer.
However, if
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 was
On Sat, Jan 31, 2009 at 5:30 AM, Francesc Alted 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 MKL (the packag
>> 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?
>
> nums
On Fri, Jan 30, 2009 at 18:13, Brian Granger 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 shared library i
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 someth
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 k
On Fri, Jan 30, 2009 at 16:32, Neal Becker wrote:
> Robert Kern wrote:
>
>> On Fri, Jan 30, 2009 at 08:22, Neal Becker 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
Robert Kern wrote:
> On Fri, Jan 30, 2009 at 08:22, Neal Becker 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.
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])
>>>
On Fri, Jan 30, 2009 at 13:18, Christopher Barker 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() simply does a particular
On Fri, Jan 30, 2009 at 12:58, frank wang 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 error says:
On Fri, Jan 30, 2009 at 14:30, Francesc Alted wrote:
> My question is, is there an elegant way to handle this problem, or it
> is a limitation of the current distutils?
Probably the latter.
> If the later, it would be
> nice it that could be solved in a future version, and several libraries
> c
On Fri, Jan 30, 2009 at 08:22, Neal Becker 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 function.
>
On Fri, Jan 30, 2009 at 11:26, Ryan May 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 strid
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 lin
> 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!), i
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 settin
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/OR&R(206) 526-6959 voic
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(
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]:
Out[0]=cnstl[0]---
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 questio
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)])
___
Nump
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]
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 differ
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 :
>
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
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):
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 positi
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
ux(i,j)
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 t
> 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 vari
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
> 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
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.
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 = n
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.
_
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
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
http://projects
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
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
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 a
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-intuiti
On Fri, Jan 30, 2009 at 22:16, Sturla Molden 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 = empty(size)
> a[:]
On Fri, Jan 30, 2009 at 09:22:46AM -0500, Neal Becker wrote:
> Now what would be _really_ cool is a special array type that would represent
> a constant array without wasting memory. boost::ublas, for example, has
> this feature.
What I would actually like is some kind of sparse masked array, w
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 @
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.
S.
> 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: http://www.linkedin.com/in/m
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
On Fri, Jan 30, 2009 at 21:54, Scott Sinclair
wrote:
> > 2009/1/30 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 g
> 2009/1/30 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
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
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
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 buil
56 matches
Mail list logo