Tip

The array types bool_, int_, complex., float., object-, Unicode., and str_ are enhanced-scalars. They are very similar to the standard Python types (without the trailing underscore) and inherit from them (except for booL and object.). They can be used in place of the standard Python types whenever desired. Whenever a data type is required, as an argument, the standard Python types are recognized as well.

Three of the data types are flexible in that they can have items that are of an arbitrary size: the str_ type, the unicode_ type, and the void type. While, you can specify an arbitrary size for these types, every item in an array is still of that specified size. The void type, for example, allows for arbitrary records to be defined as elements of the array, and can be used to define exotic types built on top of the

Table 2.1: Built-in array-scalar types corresponding to data-types for an ndarray. The bold-face types correspond to standard Python types. The object, type is special because arrays with dtype='O' do not return an array scalar on item access but instead return the actual object referenced in the array.

Table 2.1: Built-in array-scalar types corresponding to data-types for an ndarray. The bold-face types correspond to standard Python types. The object, type is special because arrays with dtype='O' do not return an array scalar on item access but instead return the actual object referenced in the array.

Type

Bit-Width

Character

bool_

boolXX

' ? '

byte

intXX

'b'

short

'h'

intc

' i '

int_

'1'

longlong

'q'

intp

'P'

ubyte

uintXX

' B'

ushort

' H'

uintc

' I'

uint

' L'

ulonglong

'Q'

uintp

' P'

single

floatXX

' f '

float.

'd'

longfloat

'g'

csingle

complexXX

' F'

complex.

' D'

clongfloat

'G'

object-

'0'

str_

'S#'

unico de

'U#'

void

0 0

Post a comment