Class to convert formats, names, titles description to a dtype. After constructing the format_parser object, the dtype attribute is the converted data-type: ``dtype = format_parser(formats, names, titles).dtype`` Attributes ---------- dtype : dtype The converte
| 86 | |
| 87 | @set_module('numpy') |
| 88 | class format_parser: |
| 89 | """ |
| 90 | Class to convert formats, names, titles description to a dtype. |
| 91 | |
| 92 | After constructing the format_parser object, the dtype attribute is |
| 93 | the converted data-type: |
| 94 | ``dtype = format_parser(formats, names, titles).dtype`` |
| 95 | |
| 96 | Attributes |
| 97 | ---------- |
| 98 | dtype : dtype |
| 99 | The converted data-type. |
| 100 | |
| 101 | Parameters |
| 102 | ---------- |
| 103 | formats : str or list of str |
| 104 | The format description, either specified as a string with |
| 105 | comma-separated format descriptions in the form ``'f8, i4, a5'``, or |
| 106 | a list of format description strings in the form |
| 107 | ``['f8', 'i4', 'a5']``. |
| 108 | names : str or list/tuple of str |
| 109 | The field names, either specified as a comma-separated string in the |
| 110 | form ``'col1, col2, col3'``, or as a list or tuple of strings in the |
| 111 | form ``['col1', 'col2', 'col3']``. |
| 112 | An empty list can be used, in that case default field names |
| 113 | ('f0', 'f1', ...) are used. |
| 114 | titles : sequence |
| 115 | Sequence of title strings. An empty list can be used to leave titles |
| 116 | out. |
| 117 | aligned : bool, optional |
| 118 | If True, align the fields by padding as the C-compiler would. |
| 119 | Default is False. |
| 120 | byteorder : str, optional |
| 121 | If specified, all the fields will be changed to the |
| 122 | provided byte-order. Otherwise, the default byte-order is |
| 123 | used. For all available string specifiers, see `dtype.newbyteorder`. |
| 124 | |
| 125 | See Also |
| 126 | -------- |
| 127 | dtype, typename, sctype2char |
| 128 | |
| 129 | Examples |
| 130 | -------- |
| 131 | >>> np.format_parser(['<f8', '<i4', '<a5'], ['col1', 'col2', 'col3'], |
| 132 | ... ['T1', 'T2', 'T3']).dtype |
| 133 | dtype([(('T1', 'col1'), '<f8'), (('T2', 'col2'), '<i4'), (('T3', 'col3'), 'S5')]) |
| 134 | |
| 135 | `names` and/or `titles` can be empty lists. If `titles` is an empty list, |
| 136 | titles will simply not appear. If `names` is empty, default field names |
| 137 | will be used. |
| 138 | |
| 139 | >>> np.format_parser(['f8', 'i4', 'a5'], ['col1', 'col2', 'col3'], |
| 140 | ... []).dtype |
| 141 | dtype([('col1', '<f8'), ('col2', '<i4'), ('col3', '<S5')]) |
| 142 | >>> np.format_parser(['<f8', '<i4', '<a5'], [], []).dtype |
| 143 | dtype([('f0', '<f8'), ('f1', '<i4'), ('f2', 'S5')]) |
| 144 | |
| 145 | """ |
no outgoing calls
no test coverage detected