larray.Session.to_pickle

Session.to_pickle(self, fname, names=None, overwrite=True, display=False, **kwargs)[source]

Dumps Array, Axis and Group objects from the current session to a file using pickle.

WARNING: never load a pickle file (.pkl or .pickle) from an untrusted source, as it can lead to arbitrary code execution.

Parameters
fnamestr

Path for the dump.

nameslist of str or None, optional

Names of Array/Axis/Group objects to dump. Defaults to all objects present in the Session.

overwrite: bool, optional

Whether or not to overwrite an existing file, if any. If False, file is updated. Defaults to True.

displaybool, optional

Whether or not to display which file is being worked on. Defaults to False.

Examples

>>> # axes
>>> a, b = Axis("a=a0..a2"), Axis("b=b0..b2")    
>>> # groups
>>> a01 = a['a0,a1'] >> 'a01'                    
>>> # arrays
>>> arr1, arr2 = ndtest((a, b)), ndtest(a)       
>>> s = Session([('a', a), ('b', b), ('a01', a01), ('arr1', arr1), ('arr2', arr2)])  
>>> # metadata
>>> s.meta.title = 'my title'                    
>>> s.meta.author = 'John Smith'                 

Save all arrays

>>> s.to_pickle('output.pkl')  

Save only some objects

>>> s.to_pickle('output.pkl', ['a', 'b', 'arr1'])