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

Function read_magic

numpy/lib/format.py:223–240  ·  view source on GitHub ↗

Read the magic string to get the version of the file format. Parameters ---------- fp : filelike object Returns ------- major : int minor : int

(fp)

Source from the content-addressed store, hash-verified

221 return MAGIC_PREFIX + bytes([major, minor])
222
223def read_magic(fp):
224 """ Read the magic string to get the version of the file format.
225
226 Parameters
227 ----------
228 fp : filelike object
229
230 Returns
231 -------
232 major : int
233 minor : int
234 """
235 magic_str = _read_bytes(fp, MAGIC_LEN, "magic string")
236 if magic_str[:-2] != MAGIC_PREFIX:
237 msg = "the magic string is not correct; expected %r, got %r"
238 raise ValueError(msg % (MAGIC_PREFIX, magic_str[:-2]))
239 major, minor = magic_str[-2:]
240 return major, minor
241
242
243def dtype_to_descr(dtype):

Callers 2

read_arrayFunction · 0.85
open_memmapFunction · 0.85

Calls 1

_read_bytesFunction · 0.85

Tested by

no test coverage detected