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

Function magic

numpy/lib/format.py:201–221  ·  view source on GitHub ↗

Return the magic string for the given file format version. Parameters ---------- major : int in [0, 255] minor : int in [0, 255] Returns ------- magic : str Raises ------ ValueError if the version cannot be formatted.

(major, minor)

Source from the content-addressed store, hash-verified

199 raise ValueError(msg % (version,))
200
201def magic(major, minor):
202 """ Return the magic string for the given file format version.
203
204 Parameters
205 ----------
206 major : int in [0, 255]
207 minor : int in [0, 255]
208
209 Returns
210 -------
211 magic : str
212
213 Raises
214 ------
215 ValueError if the version cannot be formatted.
216 """
217 if major < 0 or major > 255:
218 raise ValueError("major version must be 0 <= major < 256")
219 if minor < 0 or minor > 255:
220 raise ValueError("minor version must be 0 <= minor < 256")
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.

Callers 1

_wrap_headerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected