Re: [Numpy-discussion] Returning numpy scalars in cython functions

2010-11-18 Thread Keith Goodman
On Thu, Nov 18, 2010 at 10:08 AM, Francesc Alted wrote: > A Thursday 18 November 2010 18:51:04 Keith Goodman escrigué: >> What's the best way to make it return a numpy long int, or whatever >> it is called, that has dtype, ndim, size, etc. class methods? The >> only thing I could come up with is

Re: [Numpy-discussion] Returning numpy scalars in cython functions

2010-11-18 Thread Francesc Alted
A Thursday 18 November 2010 19:08:00 Francesc Alted escrigué: > >>> type(np.int_(2)) Err, for maximum portability you can use the int64 constructor: >>> type(np.int64(2)) Cheers, -- Francesc Alted ___ NumPy-Discussion mailing list NumPy-Discussion@s

Re: [Numpy-discussion] Returning numpy scalars in cython functions

2010-11-18 Thread Francesc Alted
A Thursday 18 November 2010 18:51:04 Keith Goodman escrigué: > The cython function below returns a long int: > > @cython.boundscheck(False) > def mysum(np.ndarray[np.int64_t, ndim=1] a): > "sum of 1d numpy array with dtype=np.int64." > cdef Py_ssize_t i > cdef int a

[Numpy-discussion] Returning numpy scalars in cython functions

2010-11-18 Thread Keith Goodman
The cython function below returns a long int: @cython.boundscheck(False) def mysum(np.ndarray[np.int64_t, ndim=1] a): "sum of 1d numpy array with dtype=np.int64." cdef Py_ssize_t i cdef int asize = a.shape[0] cdef np.int64_t asum = 0 for i in range(a