divik.core.io module

Reusable utilities for data and model I/O

divik.core.io.load_data(path)[source]

Load 2D tabular data from file

Return type

ndarray

divik.core.io.save(model, destination, **kwargs)[source]

Save model and related summaries into specified destination directory

divik.core.io.save_csv(array, fname)[source]

Save array to csv

divik.core.io.saver(fn)[source]

Register the function as handler for saving model and related summaries

The saver function should be reusable for different models exhibiting the required variables. Rather prefer checking the required attributes than the model class.

Examples

>>> from divik.core.io import saver
>>> @saver
... def my_saver(model, destination, **kwargs):
...     if not hasattr(model, 'my_custom_field_'):
...         return
...     if not 'my_param' in kwargs:
...         return
...     # custom saving logic comes here

You can also make this function configurable:

>>> import gin
>>> from divik.core.io import saver
>>> @saver
... @gin.configurable(allowlist=['my_param'])
... def configurable_saver(model, destination, my_param=None, **kwargs):
...     if not hasattr(model, 'my_custom_field_'):
...         return
...     if my_param is None:
...         return
...     # custom saving logic comes here
divik.core.io.try_load_data(path)[source]

Load 2D tabular data from file with logging

divik.core.io.try_load_xy(path)[source]

Load integer spatial coordinates with logging from file