Data Types¶
These are the data types mimicking the NumPy’s scalar hierarchy of types and allowing to describe NumPy’s dtypes in the Nani format.
They can later on be converted into NumPy’s dtype
s by calling the
resolve()
function.
Bool |
Type corresponding to numpy.bool_ . |
Object |
Type corresponding to numpy.object_ . |
Number |
Type corresponding to numpy.number . |
String |
Type corresponding to numpy.string_ . |
Unicode |
Type corresponding to numpy.unicode_ . |
Array |
Type corresponding to a NumPy (sub)array. |
Structure |
Type corresponding to a NumPy structured array. |
Bytes |
alias of String |
Str |
alias of Unicode |
-
class
nani.
Bool
(default=False, view=None)[source]¶ Type corresponding to
numpy.bool_
.-
default
¶ bool
Default value.
-
view
¶ type or None
If
None
, the owning array returns a direct reference to this boolean value, otherwise it is expected to be a class object wrapping it and accepting 2 parameters:data
, the NumPy array owning the boolean value, andindex
, its position in the array.
-
-
class
nani.
Object
(default=None, view=None)[source]¶ Type corresponding to
numpy.object_
.-
default
¶ object
Default value.
-
view
¶ type or None
If
None
, the owning array returns a direct reference to this Python object, otherwise it is expected to be a class object wrapping it and accepting 2 parameters:data
, the NumPy array owning the Python object, andindex
, its position in the array.
-
-
class
nani.
Number
(type=numpy.float_, default=0, view=None)[source]¶ Type corresponding to
numpy.number
.-
default
¶ numpy.number type
Default value.
-
view
¶ type or None
If
None
, the owning array returns a direct reference to this numeric value, otherwise it is expected to be a class object wrapping it and accepting 2 parameters:data
, the NumPy array owning the numeric value, andindex
, its position in the array.
-
-
class
nani.
String
(length, default='', view=None)[source]¶ Type corresponding to
numpy.string_
.-
length
¶ int
Number of characters.
-
default
¶ str on PY2 or bytes on PY3
Default value.
-
view
¶ type or None
If
None
, the owning array returns a direct reference to this string value, otherwise it is expected to be a class object wrapping it and accepting 2 parameters:data
, the NumPy array owning the string value, andindex
, its position in the array.
-
-
class
nani.
Unicode
(length, default='', view=None)[source]¶ Type corresponding to
numpy.unicode_
.-
length
¶ int
Number of characters.
-
default
¶ unicode on PY2 or str on PY3
Default value.
-
view
¶ type or None
If
None
, the owning array returns a direct reference to this unicode value, otherwise it is expected to be a class object wrapping it and accepting 2 parameters:data
, the NumPy array owning the unicode value, andindex
, its position in the array.
-
-
class
nani.
Array
(element_type, shape, name=None, view=None)[source]¶ Type corresponding to a NumPy (sub)array.
-
element_type
¶ nani type
Type of each element.
-
shape
¶ int or tuple of int
Shape of the array. Passing an int defines a 1D array.
-
view
¶ type or None
If
None
, a view for this array is dynamically generated by Nani, otherwise it is expected to be a class object wrapping it and accepting 1 parameter:data
, the corresponding NumPy array.
-
-
class
nani.
Structure
(fields, name=None, view=None)[source]¶ Type corresponding to a NumPy structured array.
-
fields
¶ tuple of nani.Field or compatible tuple
Fields defining the structure.
-
view
¶ type or None
If
None
, a view for this structured array is dynamically generated by Nani, otherwise it is expected to be a class object wrapping it and accepting 1 parameter:data
, the corresponding NumPy structured array.
-