Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-03 Thread James Bergstra
Thanks all for your help, I think I'm on my way again. The catch in the first place was not being confident that a PyArray_Scalar was the thing I needed. I grep'd the code for uint8, int8 and so on and could not find their definitions. On first reading I overlooked the PyArray_Scalar link in thi

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-03 Thread David Cournapeau
Francesc Alted wrote: > A Wednesday 03 March 2010 02:58:31 David Cournapeau escrigué: >>> PyObject *ret; >>> PyArray_Descr *typecode; >>> >>> >>> typecode = PyArray_DescrFromType(PyArray_UINT8); >>> ret = PyArray_Scalar(NULL, typecode, NULL); >>> Py_DECREF(typecode); >> Sorry, this is wrong, t

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-03 Thread Francesc Alted
A Wednesday 03 March 2010 02:58:31 David Cournapeau escrigué: > > PyObject *ret; > > PyArray_Descr *typecode; > > > > > > typecode = PyArray_DescrFromType(PyArray_UINT8); > > ret = PyArray_Scalar(NULL, typecode, NULL); > > Py_DECREF(typecode); > > Sorry, this is wrong, this does not work on m

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread David Cournapeau
David Cournapeau wrote: > James Bergstra wrote: > >> >> Maybe I'm missing something... but I don't think I want to create an >> array. > > Ah, I misunderstood your question. There are at least two ways: > > PyObject *ret; > ret = PyArrayScalar_New(UInt8); > > Or > > PyObject *ret; > PyArray_D

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread Travis Oliphant
PyArray_Scalar Is the one you want. Travis -- (mobile phone of) Travis Oliphant Enthought, Inc. 1-512-536-1057 http://www.enthought.com On Mar 2, 2010, at 6:46 PM, James Bergstra wrote: > On Tue, Mar 2, 2010 at 7:32 PM, David Warde-Farley > wrote: >> >> On 2-Mar-10, at 7:23 PM, James Ber

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread David Cournapeau
James Bergstra wrote: > > Maybe I'm missing something... but I don't think I want to create an array. Ah, I misunderstood your question. There are at least two ways: PyObject *ret; ret = PyArrayScalar_New(UInt8); Or PyObject *ret; PyArray_Descr *typecode; typecode = PyArray_DescrFromType

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread Christopher Barker
Warren Weckesser wrote: I want to create one of those numpy.int8 guys. >> np.int8 is a type, and so is numpy.ndarray. And they are different. >> There's lots of docs about how to make arrays, but how do I make a >> scalar? ah - I see -- you want to make a numpy scalar, not the s

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread Warren Weckesser
James Bergstra wrote: > On Tue, Mar 2, 2010 at 7:18 PM, Warren Weckesser > wrote: > >> James Bergstra wrote: >> >>> On Tue, Mar 2, 2010 at 3:09 PM, Christopher Barker >>> wrote: >>> >>> James Bergstra wrote: > Maybe I'm missing something... but I don't t

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread James Bergstra
On Tue, Mar 2, 2010 at 7:32 PM, David Warde-Farley wrote: > > On 2-Mar-10, at 7:23 PM, James Bergstra wrote: > >> Sorry... again... how do I make such a scalar... *in C* ?  What would >> be the recommended C equivalent of this python code?  Are there C >> type-checking functions for instances of t

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread David Warde-Farley
On 2-Mar-10, at 7:23 PM, James Bergstra wrote: > Sorry... again... how do I make such a scalar... *in C* ? What would > be the recommended C equivalent of this python code? Are there C > type-checking functions for instances of these objects? Are there C > functions for converting to and from

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread James Bergstra
On Tue, Mar 2, 2010 at 7:18 PM, Warren Weckesser wrote: > James Bergstra wrote: >> On Tue, Mar 2, 2010 at 3:09 PM, Christopher Barker >> wrote: >> >>> James Bergstra wrote: >>> Maybe I'm missing something... but I don't think I want to create an array. In [3]: import numpy >>>

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread Warren Weckesser
James Bergstra wrote: > On Tue, Mar 2, 2010 at 3:09 PM, Christopher Barker > wrote: > >> James Bergstra wrote: >> >>> Maybe I'm missing something... but I don't think I want to create an array. >>> >>> In [3]: import numpy >>> >>> In [4]: type(numpy.int8()) >>> Out[4]: >>> >>> In [5]: isi

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread James Bergstra
On Tue, Mar 2, 2010 at 3:09 PM, Christopher Barker wrote: > James Bergstra wrote: >> Maybe I'm missing something... but I don't think I want to create an array. >> >> In [3]: import numpy >> >> In [4]: type(numpy.int8()) >> Out[4]: >> >> In [5]: isinstance(numpy.int8(), numpy.ndarray) >> Out[5]:

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread Christopher Barker
James Bergstra wrote: > Maybe I'm missing something... but I don't think I want to create an array. > > In [3]: import numpy > > In [4]: type(numpy.int8()) > Out[4]: > > In [5]: isinstance(numpy.int8(), numpy.ndarray) > Out[5]: False right, it's a type object: In [13]: type(np.uint8) Out[13]:

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread James Bergstra
On Mon, Mar 1, 2010 at 1:44 AM, David Cournapeau wrote: > On Mon, Mar 1, 2010 at 1:35 PM, James Bergstra > wrote: >> Could someone point me to documentation (or even numpy src) that shows >> how to allocate a numpy.int8 in C, or check to see if a PyObject is a >> numpy.int8? > > In numpy, the typ

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-02-28 Thread David Cournapeau
On Mon, Mar 1, 2010 at 1:35 PM, James Bergstra wrote: > Could someone point me to documentation (or even numpy src) that shows > how to allocate a numpy.int8 in C, or check to see if a PyObject is a > numpy.int8? In numpy, the type is described in the dtype type object, so you should create the a

[Numpy-discussion] how to work with numpy.int8 in c

2010-02-28 Thread James Bergstra
Could someone point me to documentation (or even numpy src) that shows how to allocate a numpy.int8 in C, or check to see if a PyObject is a numpy.int8? Thanks, James -- http://www-etud.iro.umontreal.ca/~bergstrj ___ NumPy-Discussion mailing list NumPy