# Helper Modules¶

z2pack.io.save(obj, file_path, serializer='auto')

Saves an object to the file given in file_path. The saving is made atomic (on systems where os.replace() is atomic) by first creating a temporary file and then moving to the file_path.

Parameters
• obj – Object to be saved.

• file_path (str) – Path to the file.

• serializer (module) – The serializer to be used. Valid options are msgpack json and pickle. By default, the serializer is determined from the file extension. If this does not work, json is used to avoid data loss.

z2pack.io.load(file_path, serializer='auto')

Loads the object that was saved to file_path.

Parameters
• file_path (str) – Path to the file.

• serializer (module) – The serializer which should be used to load the result. By default, is deduced from the file extension. If no serializer is given and it cannot be deduced from the file ending, a ValueError is raised, to avoid loading corrupted data.

z2pack.io.load(file_path, serializer='auto')

Loads the object that was saved to file_path.

Parameters
• file_path (str) – Path to the file.

• serializer (module) – The serializer which should be used to load the result. By default, is deduced from the file extension. If no serializer is given and it cannot be deduced from the file ending, a ValueError is raised, to avoid loading corrupted data.

z2pack.io.save(obj, file_path, serializer='auto')

Saves an object to the file given in file_path. The saving is made atomic (on systems where os.replace() is atomic) by first creating a temporary file and then moving to the file_path.

Parameters
• obj – Object to be saved.

• file_path (str) – Path to the file.

• serializer (module) – The serializer to be used. Valid options are msgpack json and pickle. By default, the serializer is determined from the file extension. If this does not work, json is used to avoid data loss.

## Shapes¶

This module contains pre-defined shapes to use as the surface argument of surface.run() or line argument for line.run(), defining the shape of the surface or line.

class z2pack.shape.Sphere(center, radius)[source]
Parameters
• center (list) – Center of the sphere

z2pack.surface.run(