io.network — Network Serialization

The io.network module provides methods for serializing network objects.

New in version 0.1.0.

class autocnet.io.network.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
default(obj)[source]

If input object is an ndarray it will be converted into a dict holding dtype, shape and the data, base64 encoded.

autocnet.io.network.json_numpy_obj_hook(dct)[source]

Decodes a previously encoded numpy ndarray with proper shape and dtype.

Parameters

dct – (dict) json encoded ndarray

Returns

(ndarray) if input was an encoded ndarray

autocnet.io.network.load(projectname)[source]

Loads an autocnet project.

Parameters

projectname (str) – PATH to the file.

autocnet.io.network.save(network, projectname)[source]

Save an AutoCNet candiate graph to disk in a compressed file. The graph adjacency structure is stored as human readable JSON and all potentially large numpy arrays are stored as compressed binary. The project archive is a standard .zip file that can have any ending, e.g., <projectname>.project, <projectname>.zip, <projectname>.myname.

TODO: This func. writes a intermediary .npz to disk when saving. Can we write the .npz to memory?

Parameters
  • network (object) – The AutoCNet Candidate Graph object

  • projectname (str) – The PATH to the output file.