[Numpy-discussion] reporting scipy.sparse bug

2007-05-01 Thread koara
scipy 0.5.2, in scipy.sparse.lil_matrix.__mul__: the optimization for when multiplying by zero scalar is flawed. A copy of the original matrix is returned, rather than the correct zero matrix. Nasty bug because it only manifests itself with special input (zero scalar), took me some time to nail my

Re: [Numpy-discussion] ctypes TypeError. What I am doing wrong?

2007-05-01 Thread Stefan van der Walt
On Wed, May 02, 2007 at 12:38:12AM +0200, Guillem Borrell i Nogueras wrote: > lapack.argtypes=[c_int,c_int, > ndpointer(dtype=float64, >ndim=2, >flags='FORTRAN'), > c_int,c_int, >

Re: [Numpy-discussion] ctypes TypeError. What I am doing wrong?

2007-05-01 Thread Stefan van der Walt
Hi Guillem On Wed, May 02, 2007 at 12:38:12AM +0200, Guillem Borrell i Nogueras wrote: > I wrote the next function just to learn how ctypes work with numpy arrays. I > am not trying to write yet another wrapper to lapack, it's just an > experiment. (you can cut and paste the code) > > from cty

[Numpy-discussion] ctypes TypeError. What I am doing wrong?

2007-05-01 Thread Guillem Borrell i Nogueras
Hi I wrote the next function just to learn how ctypes work with numpy arrays. I am not trying to write yet another wrapper to lapack, it's just an experiment. (you can cut and paste the code) from ctypes import c_int from numpy import array,float64 from numpy.ctypeslib import load_library,ndpo

Re: [Numpy-discussion] simpliest way to check: array x is float, not integer

2007-05-01 Thread Stefan van der Walt
On Tue, May 01, 2007 at 12:05:20PM -, Simon Berube wrote: > Alternatively, as a hackjob type check you could also do an > "isinstance" check on the first element of the array since, unlike > lists, arrays have uniform elements all the way through. Or use N.issubdtype(x.dtype,int) and N.issu

Re: [Numpy-discussion] OverflowError: long too big to convert

2007-05-01 Thread Charles R Harris
On 5/1/07, Mark.Miller <[EMAIL PROTECTED]> wrote: OK...so just for future reference...does a Numpy 'long' not directly correspond to a Python 'long'? No. A numpy long corresponds, more or less, to the C long long int. In [2]: array([1],dtype=long) Out[2]: array([1], dtype=int64) Chuck

Re: [Numpy-discussion] OverflowError: long too big to convert

2007-05-01 Thread Robert Kern
Mark.Miller wrote: > OK...so just for future reference...does a Numpy 'long' not directly > correspond to a Python 'long'? There is no Numpy "long", per se. There is a numpy.long symbol exposed, but it is just the builtin long type. However, numpy has no special support for Python's unbounded lon

Re: [Numpy-discussion] OverflowError: long too big to convert

2007-05-01 Thread Mark.Miller
OK...so just for future reference...does a Numpy 'long' not directly correspond to a Python 'long'? Robert Kern wrote: > Mark.Miller wrote: >> Can someone explain this? I can't seem to coerce numpy into storing >> large integer values. I'm sure that I'm just overlooking something >> simple...

Re: [Numpy-discussion] OverflowError: long too big to convert

2007-05-01 Thread Robert Kern
Mark.Miller wrote: > Can someone explain this? I can't seem to coerce numpy into storing > large integer values. I'm sure that I'm just overlooking something > simple... > > > >>> import numpy > >>> a='1'*300 > >>> type(a) > > >>> b=int(a) > >>> type(b) > > >>> c=numpy.empty((2,2),lon

[Numpy-discussion] OverflowError: long too big to convert

2007-05-01 Thread Mark.Miller
Can someone explain this? I can't seem to coerce numpy into storing large integer values. I'm sure that I'm just overlooking something simple... >>> import numpy >>> a='1'*300 >>> type(a) >>> b=int(a) >>> type(b) >>> c=numpy.empty((2,2),long) >>> c[:]=b Traceback (most recent call la

Re: [Numpy-discussion] simpliest way to check: array x is float, not integer

2007-05-01 Thread Simon Berube
When using numpy array the type of the array is given by the "dtype" variable of the array. So if your array is int then array.dtype will be 'int32'. Numpy uses more complex data types then just int and floats so you might want to check all the available data types. Ex: In [168]: a = array([1,2,3