MCPcopy Create free account
hub / github.com/numpy/numpy / header_data_from_array_1_0

Function header_data_from_array_1_0

numpy/lib/format.py:338–363  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

336 'offsets': offsets, 'itemsize': offset})
337
338def 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
366def _wrap_header(header, version):

Callers 1

write_arrayFunction · 0.85

Calls 1

dtype_to_descrFunction · 0.85

Tested by

no test coverage detected