storage

Module Contents

Classes

Storage

This class is abstracted for all other classes

class storage.Storage(name)

This class is abstracted for all other classes providing initialization function with a name and store function to generate an HDF5 file

Parameters

name (str) – the name of the instant

set_storage_path(self, path)

set the storage path where you want to store the HDF5 file

Attention

please always use “/” in path string instead of “”

Parameters

path (str) – the storage path you want to store the result file, have to end with .h5

store_HDF5(self, root=h5py.File)

sub-method of store() for HDF5 output

Parameters

root (h5py.File, optional) – the root of file object

store_json(self, root=dict)

sub-method of store() for JSON output

Parameters

root (dict, optional) – the root of dict object

store(self, format=None, root=None)

store the pykkn structure into HDF5 or JSON

Parameters
  • format (str, optional) – the target format, by default is HDF5, can be specified as json

  • root (h5py.File or dict, optional) – the root of h5py.File or dict object

__str__(self)

rewrite the built-in method to modify the behaviors of print() to make the print result more readable

before:

>>>print(run1)

<run.Run object at 0x0000022AA45715A0>

after:

>>>print(run1)

‘run1’

here, the string ‘run1’ is the name of this instance

__repr__(self)

rewrite the built-in method to modify the behaviors of print() to make the print result more readable

before:

>>>print(run1.pipelines)

[<pipeline.Pipeline object at 0x0000022AA45715A0>]

after:

>>>print(run1.pipelines)

[‘pipe1’]

here, the strings ‘pipe1’ and ‘pipe2’ are the names of this instance

show(self)

use the method to show the detailed information about this instance for example all attributes and names. It should return a string like this:

Examples

>> msmtrun.show()

#### pipelines ####

[‘aa’, ‘bb’, ‘cc’]

#### parameters ####

[‘dd’, ‘ee’, ‘ff’]

#### attributes ####

‘author’ : ‘who’

‘author’ : ‘derGeraet’

‘pmanager’ : ‘tcorneli’

‘targettmp’ : 70

‘targetrps’ : 2

‘oil’ : ‘PA06’

add_attrs_dict(self, dict)

Add a flat Dictionary of key values as a set of attributes.

dictstr

The Dictionary consists of Key Value pairs with the keys being the names of the attribute and the value being the value assigned to the attribute

encode(self, object)

encode anything as a string

object: Any

an object which can be an instance of any class

object_string: str

an encoded string, maybe very long if the original object is large

Parameters

object (Any) –

Return type

str

decode(self, object_string)

decode a string as its original form

object_string: str

an encoded string

object: object

this is a instance of its original class

Parameters

object_string (str) –

Return type

Storage.decode.object