Class | ConversionWarning |
Warning issued when a string converter has a problem. |
Class | ConverterError |
Exception raised when an error occurs in a converter for string values. |
Class | ConverterLockError |
Exception raised when an attempt is made to upgrade a locked converter. |
Class | LineSplitter |
Object to split a string at a given delimiter or at given places. |
Class | NameValidator |
Object to validate a list of strings to use as field names. |
Class | StringConverter |
Factory class for function transforming a string into another object (int, float). |
Function | _decode_line |
Decode bytes from binary input streams. |
Function | _is_bytes_like |
Check whether obj behaves like a bytes object. |
Function | _is_string_like |
Check whether obj behaves like a string. |
Function | easy_dtype |
Convenience function to create a np.dtype object. |
Function | flatten_dtype |
Unpack a structured data-type by collapsing nested fields and/or fields with a shape. |
Function | has_nested_fields |
Returns whether one or several fields of a dtype are nested. |
Function | str2bool |
Tries to transform a string supposed to represent a boolean to a boolean. |
Decode bytes from binary input streams.
Defaults to decoding from 'latin1'. That differs from the behavior of np.compat.asunicode that decodes from 'ascii'.
line
.decoded_line : str
Convenience function to create a np.dtype
object.
The function processes the input dtype
and matches it with the given
names.
np.dtype
function, or a sequence of types.names
can be a string of a comma-separated list
of names.NameValidator
.>>> np.lib._iotools.easy_dtype(float) dtype('float64') >>> np.lib._iotools.easy_dtype("i4, f8") dtype([('f0', '<i4'), ('f1', '<f8')]) >>> np.lib._iotools.easy_dtype("i4, f8", defaultfmt="field_%03i") dtype([('field_000', '<i4'), ('field_001', '<f8')])
>>> np.lib._iotools.easy_dtype((int, float, float), names="a,b,c") dtype([('a', '<i8'), ('b', '<f8'), ('c', '<f8')]) >>> np.lib._iotools.easy_dtype(float, names="a,b,c") dtype([('a', '<f8'), ('b', '<f8'), ('c', '<f8')])
Unpack a structured data-type by collapsing nested fields and/or fields with a shape.
Note that the field names are lost.
>>> dt = np.dtype([('name', 'S4'), ('x', float), ('y', float), ... ('block', int, (2, 3))]) >>> np.lib._iotools.flatten_dtype(dt) [dtype('S4'), dtype('float64'), dtype('float64'), dtype('int64')] >>> np.lib._iotools.flatten_dtype(dt, flatten_base=True) [dtype('S4'), dtype('float64'), dtype('float64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64')]
Returns whether one or several fields of a dtype are nested.
ndtype
does not have a names
attribute.>>> dt = np.dtype([('name', 'S4'), ('x', float), ('y', float)]) >>> np.lib._iotools.has_nested_fields(dt) False
Tries to transform a string supposed to represent a boolean to a boolean.
value
.>>> np.lib._iotools.str2bool('TRUE') True >>> np.lib._iotools.str2bool('false') False