Get the dictionary of header metadata from a numpy.ndarray. Parameters ---------- array : numpy.ndarray Returns ------- d : dict This has the appropriate entries for writing its string representation to the header of the file.
(array)
| 336 | 'offsets': offsets, 'itemsize': offset}) |
| 337 | |
| 338 | def header_data_from_array_1_0(array): |
| 339 | """ Get the dictionary of header metadata from a numpy.ndarray. |
| 340 | |
| 341 | Parameters |
| 342 | ---------- |
| 343 | array : numpy.ndarray |
| 344 | |
| 345 | Returns |
| 346 | ------- |
| 347 | d : dict |
| 348 | This has the appropriate entries for writing its string representation |
| 349 | to the header of the file. |
| 350 | """ |
| 351 | d = {'shape': array.shape} |
| 352 | if array.flags.c_contiguous: |
| 353 | d['fortran_order'] = False |
| 354 | elif array.flags.f_contiguous: |
| 355 | d['fortran_order'] = True |
| 356 | else: |
| 357 | # Totally non-contiguous data. We will have to make it C-contiguous |
| 358 | # before writing. Note that we need to test for C_CONTIGUOUS first |
| 359 | # because a 1-D array is both C_CONTIGUOUS and F_CONTIGUOUS. |
| 360 | d['fortran_order'] = False |
| 361 | |
| 362 | d['descr'] = dtype_to_descr(array.dtype) |
| 363 | return d |
| 364 | |
| 365 | |
| 366 | def _wrap_header(header, version): |
no test coverage detected