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

Warren Weckesser warren.weckesser at enthought.com
Tue Mar 2 19:48:04 EST 2010


James Bergstra wrote:
> On Tue, Mar 2, 2010 at 7:18 PM, Warren Weckesser
> <warren.weckesser at enthought.com> wrote:
>   
>> James Bergstra wrote:
>>     
>>> On Tue, Mar 2, 2010 at 3:09 PM, Christopher Barker
>>> <Chris.Barker at 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* ?

Whoops.  So you said, in the subject even.   :$


Warren


"Oh.  That's different... never mind."  - E Litella.

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




More information about the NumPy-Discussion mailing list