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

James Bergstra bergstrj@iro.umontreal...
Tue Mar 2 18:12:50 CST 2010


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?

> There's got to be a a way, though I can't tell you what it is. But I'm
> curious why you want that from C. It's a Python object, why not create
> it in Python?
It's for Theano. (http://www.deeplearning.net/software/theano)

Theano generates some c functions that are supposed to return such
np.int8 instances, and they don't.  Same goes for all the other scalar
types too, but I didn't want to complicate my original question.  I
want to be able to generate all the{int,uint}{8,16,32,64}
combinations.

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


More information about the NumPy-Discussion mailing list