[Numpy-discussion] ANNOUNCE: numarray-0.6

Sebastian Haase haase at msg.ucsf.edu
Mon Jul 28 14:03:04 CDT 2003


> > "However, there is a new API function which I added in
> > response to your
> >   last post: NA_NewAllFromBuffer() which enables you to
> > create arrays in C
> >   from existing buffer objects rather than just C arrays."
> >
> > The 0.6 documentation doesn't mention that function - for
> > now I probably have to read the source, right ?
>
> Yes.  The signature is:
>
> PyArrayObject * NA_NewAllFromBuffer  (int ndim, maybelong *shape,
> NumarrayType type, PyObject *bufferObject, maybelong byteoffset,
> maybelong bytestride, int byteorder, int aligned, int writeable)
>
Seems to work right away.
But now I get this:
>>> r = na.array( [ 2,3,4,5] , type=F.na.Float32 )
>>> r
array([ 2.,  3.,  4.,  5.], type=Float32)
>>> r/10
Traceback (most recent call last):
  File "<input>", line 1, in ?
TypeError: unsupported operand type(s) for /: 'NumArray' and 'int'
>>> r/10.
Traceback (most recent call last):
  File "<input>", line 1, in ?
TypeError: unsupported operand type(s) for /: 'NumArray' and 'float'
>>>

Sorry to frighten you... :-(
I am just experimenting with
from __future__ import division

Apparently taking that line out again fixes the problem.
I am actually not sure what the "proposed policy" is on that future division
thing; I just thought I could simplify some explanation to non-Python people
if  1/3 is not 0.
Probably numarray has more important things to worry about - but maybe you
can put it on the list..

Thanks for your work.
Sebastian







More information about the Numpy-discussion mailing list