[Numpy-discussion] how to use ldexp?

2009-05-21 Thread dmitrey
hi all,
I have tried the example from numpy/add_newdocs.py

np.ldexp(5., 2)
but instead of the 20 declared there it yields
TypeError: function not supported for these types, and can't coerce
safely to supported types

I have tried arrays but it yields same error
 np.ldexp(np.array([5., 2.]), np.array([2, 1]))
Traceback (innermost last):
  File stdin, line 1, in module
TypeError: function not supported for these types, and can't coerce
safely to supported types

So, how can I use ldexp?
np.__version__ = '1.4.0.dev6972'

Thank you in advance,
D.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] numpy ufuncs and COREPY - any info?

2009-05-21 Thread dmitrey
hi all,
has anyone already tried to compare using an ordinary numpy ufunc vs
that one from corepy, first of all I mean the project
http://socghop.appspot.com/student_project/show/google/gsoc2009/python/t124024628235

It would be interesting to know what is speedup for (eg) vec ** 0.5 or
(if it's possible - it isn't pure ufunc) numpy.dot(Matrix, vec). Or
any another example.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how to use ldexp?

2009-05-21 Thread David Cournapeau
dmitrey wrote:
 hi all,
 I have tried the example from numpy/add_newdocs.py

 np.ldexp(5., 2)
 but instead of the 20 declared there it yields
 TypeError: function not supported for these types, and can't coerce
 safely to supported types

   

Which OS/Compiler are you using ?

David
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how to use ldexp?

2009-05-21 Thread David Cournapeau
dmitrey wrote:
 I have updated numpy to latest '1.4.0.dev7008', but the bug still
 remains.
 I use KUBUNTU 9.04, compilers - gcc (using build-essential), gfortran.
 D.
   

Can you post the build output (after having removed the build directory
: rm -rf build  python setup.py build  build.log) ?

David
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how to use ldexp?

2009-05-21 Thread dmitrey
On May 21, 11:29 am, David Cournapeau da...@ar.media.kyoto-u.ac.jp
wrote:
 dmitrey wrote:
  I have updated numpy to latest '1.4.0.dev7008', but the bug still
  remains.
  I use KUBUNTU 9.04, compilers - gcc (using build-essential), gfortran.
  D.

 Can you post the build output (after having removed the build directory
 : rm -rf build  python setup.py build  build.log) ?

 David

ok, it's here
http://pastebin.com/mb021e11
D.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how to use ldexp?

2009-05-21 Thread Pauli Virtanen
Thu, 21 May 2009 01:45:54 -0700, dmitrey wrote:

 I have updated numpy to latest '1.4.0.dev7008', but the bug still
 remains.
 I use KUBUNTU 9.04, compilers - gcc (using build-essential), gfortran.

Worksforme on Ubuntu 9.04, on python2.6 and python2.5. Should be the same 
platform.

-- 
Pauli Virtanen

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how to use ldexp?

2009-05-21 Thread Pauli Virtanen
Thu, 21 May 2009 09:26:18 +, Pauli Virtanen wrote:

 Thu, 21 May 2009 01:45:54 -0700, dmitrey wrote:
 
 I have updated numpy to latest '1.4.0.dev7008', but the bug still
 remains.
 I use KUBUNTU 9.04, compilers - gcc (using build-essential), gfortran.
 
 Worksforme on Ubuntu 9.04, on python2.6 and python2.5. Should be the
 same platform.

This was on 32-bit machine. I can reproduce this on a 64-bit platform, 
current SVN head:

 np.ldexp(5, 2)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: function not supported for these types, and can't coerce 
safely to supported types
 np.ldexp(5, np.int32(2))
20.0
 np.ldexp.types
['fi-f', 'di-d', 'gi-g']

So for some reason the second argument tries to cast Python int to int64, 
and there's no loop to handle this.

-- 
Pauli Virtanen

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] matrix default to column vector?

2009-05-21 Thread Jason Rennie
By default, it looks like a 1-dim ndarray gets converted to a row vector by
the matrix constructor.  This seems to lead to some odd behavior such as
a[1] yielding the 2nd element as an ndarray and throwing an IndexError as a
matrix.  Is it possible to set a flag to make the default be a column
vector?

Thanks,

Jason

-- 
Jason Rennie
Research Scientist, ITA Software
http://www.itasoftware.com/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] where are the benefits of ldexp and/or array times 2?

2009-05-21 Thread dmitrey
Hi all,
I expected to have some speedup via using ldexp or multiplying an
array by a power of 2 (doesn't it have to perform a simple shift of
mantissa?), but I don't see the one.

Have I done something wrong? See the code below.

from scipy import rand
from numpy import dot, ones, zeros, array, ldexp
from time import time
N = 1500
A = rand(N, N)

b = rand(N)
b2 = 2*ones(A.shape, 'int32')

I = 100
t = time()

for i in xrange(I):
dot(A, b) # N^2 multiplications + some sum operations
#A * 2.1 # N^2 multiplications, so it should consume no greater
than 1st line time
#ldexp(A, b2) # it should consume no greater than prev line time,
isn't it?

print 'time elapsed:', time() - t

# 1st case: 0.62811088562
# 2nd case: 2.00850605965
# 3rd case: 6.79027700424

# Let me also note -
# 1) using b = 2 * ones(N) or b = zeros(N) doesn't yield any speedup
vs b = rand()
# 2) using A * 2.0 (or mere 2) instead of 2.1 doesn't yield any
speedup, despite it is exact integer power of 2.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] where are the benefits of ldexp and/or array times 2?

2009-05-21 Thread Robert Kern
On Thu, May 21, 2009 at 10:26, dmitrey dmitrey.kros...@scipy.org wrote:
 Hi all,
 I expected to have some speedup via using ldexp or multiplying an
 array by a power of 2 (doesn't it have to perform a simple shift of
 mantissa?),

Addition of the exponent, not shift of the mantissa.

 but I don't see the one.

I said there *might* be a speedup, but it was probably going to be
insignificant. The overhead of using frexp and ldexp probably
outweighs any benefits.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth.
  -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] ANN: Cython 0.11.2 released

2009-05-21 Thread Dag Sverre Seljebotn
 Where can I find release notes?  (It would be helpful if I can point to a
 URL as part of the fedora release)


OK, I put my email announcement up here:

http://wiki.cython.org/ReleaseNotes-0.11.2

Tell me if you need something else (different format or level of detail --
the list of tickets on trac is always the most accurate thing).

Dag Sverre

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] memoryerror with numpy.fromfile

2009-05-21 Thread Michael Hearne
I am getting a MemoryError from a numpy.fromfile() call in an  
application I am trying to deploy.  Normally I would assume that this  
would mean that I don't have enough memory available on the system.   
However, if I run vmstat (Linux) at the same time as my process, I see  
that I have 3+ Gigabytes of memory free, and no swap space being  
used.  I can't think of a way to track down this problem, so I'm  
punting to the list.  The only thing I can imagine is that someone  
Python has been allocated X amount of space (very small relative to  
the memory actually available), and is asking for more than X.  I  
don't know if this is true, or if there is even a way to check it.   
Sigh.

Version info:
Linux RedHat 5 kernel 2.6.18-128.1.10.el5PAE
Python 2.5.4 -- EPD_Py25 4.3.0
numpy 1.3.0

Can anyone suggest more tests that I can do?

Thanks,

Mike
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] memoryerror with numpy.fromfile

2009-05-21 Thread Pauli Virtanen
Thu, 21 May 2009 10:31:28 -0600, Michael Hearne wrote:

 I am getting a MemoryError from a numpy.fromfile() call in an
 application I am trying to deploy.  Normally I would assume that this
 would mean that I don't have enough memory available on the system.
 However, if I run vmstat (Linux) at the same time as my process, I see
 that I have 3+ Gigabytes of memory free, and no swap space being used. 

If you are on a 32-bit platform, the maximum addressable memory for a 
single process is limited to 3 GB, and what can be allocated can be less 
than this because of memory fragmentation. Also, you should check that 
you don't have an ulimit set for virtual/RSS memory.

-- 
Pauli Virtanen

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] memoryerror with numpy.fromfile

2009-05-21 Thread Charles R Harris
On Thu, May 21, 2009 at 10:31 AM, Michael Hearne mhea...@usgs.gov wrote:

 I am getting a MemoryError from a numpy.fromfile() call in an
 application I am trying to deploy.  Normally I would assume that this
 would mean that I don't have enough memory available on the system.
 However, if I run vmstat (Linux) at the same time as my process, I see
 that I have 3+ Gigabytes of memory free, and no swap space being
 used.  I can't think of a way to track down this problem, so I'm
 punting to the list.  The only thing I can imagine is that someone
 Python has been allocated X amount of space (very small relative to
 the memory actually available), and is asking for more than X.  I
 don't know if this is true, or if there is even a way to check it.
 Sigh.

 Version info:
 Linux RedHat 5 kernel 2.6.18-128.1.10.el5PAE
 Python 2.5.4 -- EPD_Py25 4.3.0
 numpy 1.3.0

 Can anyone suggest more tests that I can do?


How big is the file and what type are you importing to?

Chuck
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] wiki page correction

2009-05-21 Thread Grant Kelly
It's an immutable page. Can someone who already has access make the edit?


On Wed, May 20, 2009 at 2:36 PM, Pauli Virtanen p...@iki.fi wrote:
 Wed, 20 May 2009 12:08:46 -0700, Grant Kelly wrote:

 I believe there is an error on this wiki page:

 http://www.scipy.org/NumPy_for_Matlab_Users


 MATLAB
   y=x(2,:)
 PYTHON
   y = x[2,:].copy()

 shouldn't the Python version be:
   y = x[1,:].copy()

 If not, please advise.

 Yes, it should be x[1,:].copy(). Please feel free to correct it.

 --
 Pauli Virtanen

 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] memoryerror with numpy.fromfile

2009-05-21 Thread Michael Hearne
All:  Never mind!  The file I was attempting to read was part of an  
(apparently) silently incomplete download, and as such, the file size  
didn't match the metadata in the header file describing the data file,  
and I was reading beyond the end of the file.


I would submit that MemoryError is perhaps a little misleading for  
this particular case, but oh well.


Thanks for the comments!

--Mike

On May 21, 2009, at 11:46 AM, Charles R Harris wrote:




On Thu, May 21, 2009 at 10:31 AM, Michael Hearne mhea...@usgs.gov  
wrote:

I am getting a MemoryError from a numpy.fromfile() call in an
application I am trying to deploy.  Normally I would assume that this
would mean that I don't have enough memory available on the system.
However, if I run vmstat (Linux) at the same time as my process, I see
that I have 3+ Gigabytes of memory free, and no swap space being
used.  I can't think of a way to track down this problem, so I'm
punting to the list.  The only thing I can imagine is that someone
Python has been allocated X amount of space (very small relative to
the memory actually available), and is asking for more than X.  I
don't know if this is true, or if there is even a way to check it.
Sigh.

Version info:
Linux RedHat 5 kernel 2.6.18-128.1.10.el5PAE
Python 2.5.4 -- EPD_Py25 4.3.0
numpy 1.3.0

Can anyone suggest more tests that I can do?

How big is the file and what type are you importing to?

Chuck


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] memoryerror with numpy.fromfile

2009-05-21 Thread Pauli Virtanen
Thu, 21 May 2009 12:14:18 -0600, Michael Hearne wrote:

 All:  Never mind!  The file I was attempting to read was part of an
 (apparently) silently incomplete download, and as such, the file size
 didn't match the metadata in the header file describing the data file,
 and I was reading beyond the end of the file.
 
 I would submit that MemoryError is perhaps a little misleading for this
 particular case, but oh well.

Well, that it raises MemoryError in this case is a bug, so maybe a ticket 
should be filed.

There's another bug associated with reading empty files:

http://projects.scipy.org/numpy/ticket/1115

which is maybe related.

-- 
Pauli Virtanen

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] wiki page correction

2009-05-21 Thread Pauli Virtanen
Thu, 21 May 2009 10:54:21 -0700, Grant Kelly wrote:
 It's an immutable page. Can someone who already has access make the
 edit?

Umm, are you sure? I don't see any ACL's on the page. (Though you need to 
register an account on the wiki before editing.)

-- 
Pauli Virtanen

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Home for pyhdf5io?

2009-05-21 Thread Dag Sverre Seljebotn
Dag Sverre Seljebotn wrote:
 albert.thuswald...@gmail.com wrote:
 Dear list,
 I'm writing this because i have developed a small python module that 
 might be of interest to you the readers of this list:

 http://code.google.com/p/pyhdf5io/

 It basically implements load/save functions that mimic the behaviour of 
 those found in Matlab, i.e. with them you can store your variables from 
 within the interactive shell (IPython, python) or from within a 
 function, and then load them back in again. One important difference is 
 that the hdf5 format is used to store the variables, which comes with a 
 a number of benefits:
 - a open standard file format which is supported by many applications.
 - completely portable file format across different platforms.

 Read more here: http://www.hdfgroup.org/HDF5/whatishdf5.html

 And now to the question:

 I think that this module is to small to be developed and maintained on 
 its on, I think It would be better if it could be part of some larger 
 project. So where would pyhdf5io fit in?
 Any tips and ideas are highly appreciate
 
 I'd expect to find it in
 
 http://h5py.alfven.org/
 
 I think...
 

Please disregard this, I didn't notice you had a PyTable dependency.

-- 
Dag Sverre
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Home for pyhdf5io?

2009-05-21 Thread David Warde-Farley
Hi Albert,

So this is a wrapper on top of PyTables to implement load() and  
save()? Neat.

Obviously if you're installing PyTables, you can do a lot better and  
organize your data hierarchically without the messiness of Matlab  
structures, walk the node tree, all kinds of fun stuff, but if  you're  
an expatriate matlab user and just want to save some matrices... this  
is great. Notably, that was one of my gripes about ipython+numpy+scipy 
+matplotlib when I first came from Matlab.

I think you should send a message to the PyTables list, ask Francesc  
if he thinks it has a place in PyTables for it as a 'lite' wrapper or  
something, for people who need to save data but don't need/are  
intimidated by all the features that PyTables provides.

David

On 21-May-09, at 4:04 PM, albert.thuswald...@gmail.com wrote:

 Dear list,
 I'm writing this because i have developed a small python module that  
 might be of interest to you the readers of this list:

 http://code.google.com/p/pyhdf5io/

 It basically implements load/save functions that mimic the behaviour  
 of those found in Matlab, ie with them you can store your variables  
 from within the interactive shell (IPython, python) or from within a  
 function, and then load them back in again. One important difference  
 is that the hdf5 format is used to store the variables, which comes  
 with aa number of benefits:
 - a open standard file format which is supported by many applications.
 - completely portable file format across different platforms.

 Read more here: http://www.hdfgroup.org/HDF5/whatishdf5.html

 And now to the question:

 I think that this module is to small to be developed and maintained  
 on its on, I think It would be better if it could be part of some  
 larger project. So where would pyhdf5io fit in?
 Any tips and ideas are highly appreciated.

 Thanks.

 /Albert
 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Home for pyhdf5io?

2009-05-21 Thread Albert Thuswaldner
On Thu, May 21, 2009 at 22:38, David Warde-Farley d...@cs.toronto.edu wrote:
 Hi Albert,

 So this is a wrapper on top of PyTables to implement load() and
 save()? Neat.

Yes, you got the idea. in its most simplest form you can type:

 hdf5save()

And all your local variables are saved to a file with the default file
name hdf5io.h5.
Of course it also allows you to specify a file name and what variables
you would like to save.
As it is based on hdf5 you can also store the variables to a certain
group within the file
(If you know how hdf5 works, you probably know what I'm talking
about).  Appending data to existing
hdf5-files is also possible.

 Obviously if you're installing PyTables, you can do a lot better and
 organize your data hierarchically without the messiness of Matlab
 structures, walk the node tree, all kinds of fun stuff, but if  you're
 an expatriate matlab user and just want to save some matrices... this
 is great. Notably, that was one of my gripes about ipython+numpy+scipy
 +matplotlib when I first came from Matlab.

Exactly!

 I think you should send a message to the PyTables list, ask Francesc
 if he thinks it has a place in PyTables for it as a 'lite' wrapper or
 something, for people who need to save data but don't need/are
 intimidated by all the features that PyTables provides.

Actually, I just e-mail Francesc, see what he thinks.

Thanks for your reply. Also thanks to the others who also have replied

/Albert

 David

 On 21-May-09, at 4:04 PM, albert.thuswald...@gmail.com wrote:

 Dear list,
 I'm writing this because i have developed a small python module that
 might be of interest to you the readers of this list:

 http://code.google.com/p/pyhdf5io/

 It basically implements load/save functions that mimic the behaviour
 of those found in Matlab, ie with them you can store your variables
 from within the interactive shell (IPython, python) or from within a
 function, and then load them back in again. One important difference
 is that the hdf5 format is used to store the variables, which comes
 with aa number of benefits:
 - a open standard file format which is supported by many applications.
 - completely portable file format across different platforms.

 Read more here: http://www.hdfgroup.org/HDF5/whatishdf5.html

 And now to the question:

 I think that this module is to small to be developed and maintained
 on its on, I think It would be better if it could be part of some
 larger project. So where would pyhdf5io fit in?
 Any tips and ideas are highly appreciated.

 Thanks.

 /Albert
 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion

 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion