Package gromacs :: Package analysis :: Module collections :: Class Collection
[hide private]
[frames] | no frames]

Class Collection

source code

object --+    
         |    
      list --+
             |
            Collection

Multiple objects (organized as a list).

Methods are applied to all objects in the Collection and returned as new Collection:

>>> from gromacs.analysis.collections import Collection
>>> animals = Collection(['ant', 'boar', 'ape', 'gnu'])
>>> animals.startswith('a')
Collection([True, False, True, False])

Similarly, attributes are returned as a Collection.

Using :meth:`Collection.save` one can save the whole collection to disk and restore it later with the :meth:`Collection.load` method

>>> animals.save('zoo')
>>> arc = Collection()
>>> arc.load('zoo')
>>> arc.load('zoo', append=True)
>>> arc
['ant', 'boar', 'ape', 'gnu', 'ant', 'boar', 'ape', 'gnu']
Instance Methods [hide private]
 
save(self, filename)
Pickle the whole collection to *filename*.
source code
 
load(self, filename, append=False)
Load collection from pickled file *filename*.
source code
 
tolist(self)
Return contents as a simple list.
source code
 
_canonicalize(self, filename)
Use .collection as extension unless provided
source code
 
__getnewargs__(self, *args, **kwargs)
Provide proper initialization to make pickling with protocol 2 work
source code
 
__getattribute__(self, attr)
x.__getattribute__('name') <==> x.name
source code
 
__add__(self, x)
x+y
source code
 
__repr__(self)
repr(x)
source code

Inherited from list: __contains__, __delitem__, __delslice__, __eq__, __ge__, __getitem__, __getslice__, __gt__, __hash__, __iadd__, __imul__, __init__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __reversed__, __rmul__, __setitem__, __setslice__, append, count, extend, index, insert, pop, remove, reverse, sort

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

save(self, filename)

source code 

Pickle the whole collection to *filename*.

If no extension is provided, ".collection" is appended.

load(self, filename, append=False)

source code 

Load collection from pickled file *filename*.

*append* determines if the saved collection is added to the current one or if it replaces the current content.

If no extension is provided, ".collection" is appended.

__getattribute__(self, attr)

source code 

x.__getattribute__('name') <==> x.name

Overrides: object.__getattribute__
(inherited documentation)

__add__(self, x)
(Addition operator)

source code 

x+y

Overrides: list.__add__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)