| Multivariate Pattern Analysis in Python

### Navigation

- index
- next |
- previous |
- ExpPsy Project |
- NeuroDebian Project |
- PyMVPA 0.4.x Home |
- PyMVPA Home |
- Documentation »
- Module Reference »

This content refers to the previous stable release of PyMVPA. Please visit www.pymvpa.org for the most recent version of PyMVPA and its documentation.

# misc.io.hamster

## Module: `misc.io.hamster`

Inheritance diagram for `mvpa.misc.io.hamster`:

Helper for simple storage facility via cPickle and optionally zlib

## `Hamster`

class `mvpa.misc.io.hamster.``Hamster`(*args, **kwargs)

  Bases: `object`

  Simple container class with basic IO capabilities.

  It is capable of storing itself in a file, or loading from a file using cPickle (optionally via zlib from compressed files). Any serializable object can be bound to a hamster to be stored.

  To undig burried hamster use Hamster(filename). Here is an example:

      >>> h = Hamster(bla='blai')
      >>> h.boo = N.arange(5)
      >>> h.dump(filename)
      ...
      >>> h = Hamster(filename)

  Since Hamster introduces methods dump, asdict and property ‘registered’, those names cannot be used to assign an attribute, nor provided in among constructor arguments.

  Initialize Hamster.

  Providing a single parameter string would treat it as a filename from which to undig the data. Otherwise all keyword parameters are assigned into the attributes of the object.

  `asdict`()

    Return registered data as dictionary

  `dump`(filename, compresslevel='auto')

    Bury the hamster into the file

    Parameters:

    - filename (str) – Name of the target file. When writing to a compressed file the filename gets a ‘.gz’ extension if not already specified. This is necessary as the constructor uses the extension to decide whether it loads from a compressed or uncompressed file.
    - compresslevel (‘auto’ or int) – Compression level setting passed to gzip. When set to ‘auto’, if filename ends with ‘.gz’ compresslevel is set to 5, 0 otherwise. However, when compresslevel is set to 0 gzip is bypassed completely and everything is written to an uncompressed file.

  `registered`

    List registered attributes.

### Navigation

- index
- next |
- previous |
- ExpPsy Project |
- NeuroDebian Project |
- PyMVPA 0.4.x Home |
- PyMVPA Home |
- Documentation »
- Module Reference »