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

James Bergstra bergstrj@iro.umontreal...
Tue Mar 2 18:23:57 CST 2010


On Tue, Mar 2, 2010 at 7:18 PM, Warren Weckesser
<warren.weckesser@enthought.com> wrote:
> James Bergstra wrote:
>> On Tue, Mar 2, 2010 at 3:09 PM, Christopher Barker
>> <Chris.Barker@noaa.gov> 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]: <type 'numpy.int8'>
>>>>
>>>> In [5]: isinstance(numpy.int8(), numpy.ndarray)
>>>> Out[5]: False
>>>>
>>> right, it's a type object:
>>>
>>> In [13]: type(np.uint8)
>>> Out[13]: <type 'type'>
>>>
>>>
>> Agreed :)
>>
>>>> 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?
>>
>
> In [1]: import numpy as np
>
> In [2]: x = np.uint8(23)
>
> In [3]: x
> Out[3]: 23
>
> In [4]: type(x)
> Out[4]: <type 'numpy.uint8'>

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 C scalars?

Basically, is there a C API for working with these numpy scalars?

-- 
http://www-etud.iro.umontreal.ca/~bergstrj


More information about the NumPy-Discussion mailing list