Skip to content

hertzforge.io.plain_numpy

plain_numpy

Read NumPy files without running anything in them.

A .npy or .npz member with an object array holds a pickle, and unpickling runs whatever the pickle says. A file is something a person was sent and drops on the window, so nothing here hands a file's pickle to pickle.load or allow_pickle=True: an array of objects is refused in words, and the one kind a real file needs, the node id arrays in a geometry's traceline and element (PlainNpz.with_objects), is rebuilt from a pickle that may name nothing but numpy's arrays.

Classes:

Name Description
PlainNpz

An open .npz, used as np.load's result is, whose arrays of

Functions:

Name Description
npy_dtype

What a .npy declares it holds, from its header alone. Raises

read_npy

A .npy of plain data; ValueError for an array of objects, or for

Classes

PlainNpz

PlainNpz(path: str | PathLike)

An open .npz, used as np.load's result is, whose arrays of objects are refused in words.

Methods:

Name Description
with_objects

An array that may hold objects, rebuilt from plain data only.

Methods:
with_objects
with_objects(name: str) -> ndarray

An array that may hold objects, rebuilt from plain data only.

Functions:

npy_dtype

npy_dtype(path: str | PathLike) -> dtype

What a .npy declares it holds, from its header alone. Raises ValueError for a file that is not a NumPy file.

read_npy

read_npy(path: str | PathLike) -> ndarray

A .npy of plain data; ValueError for an array of objects, or for a file that is not a NumPy file.