Table Of Contents

Previous topic

misc.plot.topo

Next topic

misc.stats

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.state

Module: misc.state

Inheritance diagram for mvpa.misc.state:

Classes to control and store state information.

It was devised to provide conditional storage

Classes

AttributesCollector

class mvpa.misc.state.AttributesCollector(name, bases, dict)

Bases: type

Intended to collect and compose StateCollection for any child class of this metaclass

ClassWithCollections

class mvpa.misc.state.ClassWithCollections(descr=None, **kwargs)

Bases: object

Base class for objects which contain any known collection

Classes inherited from this class gain ability to access collections and their items as simple attributes. Access to collection items “internals” is done via <collection_name> attribute and interface of a corresponding Collection.

descr

Description of the object if any

reset()

Collection

class mvpa.misc.state.Collection(items=None, owner=None, name=None)

Bases: object

Container of some CollectableAttributes.

Groups :
  • Public Access Functions: isKnown
  • Access Implementors: _getListing, _getNames
  • Mutators: __init__
  • R/O Properties: listing, names, items

XXX Seems to be not used and duplicating functionality: _getListing (thus listing property)

Initialize the Collection

Parameters:
  • items (dict of CollectableAttribute’s) – items to initialize with
  • owner (object) – an object to which collection belongs
  • name (basestring) – name of the collection (as seen in the owner, e.g. ‘states’)
add(item)

Add a new CollectableAttribute to the collection

Parameters:item (CollectableAttribute) – or of derived class. Must have ‘name’ assigned
TODO: we should make it stricter to don’t add smth of

wrong type into Collection since it might lead to problems

Also we might convert to __setitem__

get(index, default)

Access the value by a given index.

Mimiquing regular dictionary behavior, if value cannot be obtained (i.e. if any exception is caught) return default value.

isKnown(index)

Returns True if state index is known at all

isSet(index=None)

If item (or any in the present or listed) was set

Parameters:index (None or basestring or list of basestring) – What items to check if they were set in the collection
items
listing = 'property'
name
names

Return ids for all registered state variables

owner
remove(index)

Remove item from the collection

reset(index=None)

Reset the state variable defined by index

whichSet()

Return list of indexes which were set

Harvestable

class mvpa.misc.state.Harvestable(harvest_attribs=None, copy_attribs='copy', **kwargs)

Bases: mvpa.misc.state.ClassWithCollections

Classes inherited from this class intend to collect attributes within internal processing.

Subclassing Harvestable we gain ability to collect any internal data from the processing which is especially important if an object performs something in loop and discards some intermidiate possibly interesting results (like in case of CrossValidatedTransferError and states of the trained classifier or TransferError).

Note

Available state variables:

  • harvested: Store specified attributes of classifiers at each split

(States enabled by default are listed with +)

See also

Please refer to the documentation of the base class for more information:

ClassWithCollections

Initialize state of harvestable

Parameters:
  • harvest_attribs (list of basestr or dicts) – What attributes of call to store and return within harvested state variable. If an item is a dictionary, following keys are used [‘name’, ‘copy’]
  • copy_attribs (None or basestr) – Default copying. If None – no copying, ‘copy’ - shallow copying, ‘deepcopy’ – deepcopying
  • enable_states (None or list of basestring) – Names of the state variables which should be enabled additionally to default ones
  • disable_states (None or list of basestring) – Names of the state variables which should be disabled
harvest_attribs

ParameterCollection

class mvpa.misc.state.ParameterCollection(items=None, owner=None, name=None)

Bases: mvpa.misc.state.Collection

Container of Parameters for a stateful object.

Initialize the Collection

Parameters:
  • items (dict of CollectableAttribute’s) – items to initialize with
  • owner (object) – an object to which collection belongs
  • name (basestring) – name of the collection (as seen in the owner, e.g. ‘states’)
resetvalue(index, missingok=False)

Reset all parameters to default values

SampleAttributesCollection

class mvpa.misc.state.SampleAttributesCollection(items=None, owner=None, name=None)

Bases: mvpa.misc.state.Collection

Container for data and attributes of samples (ie data/labels/chunks/...)

Initialize the Collection

Parameters:
  • items (dict of CollectableAttribute’s) – items to initialize with
  • owner (object) – an object to which collection belongs
  • name (basestring) – name of the collection (as seen in the owner, e.g. ‘states’)

StateCollection

class mvpa.misc.state.StateCollection(items=None, owner=None)

Bases: mvpa.misc.state.Collection

Container of StateVariables for a stateful object.

Groups :
  • Public Access Functions: isKnown, isEnabled, isActive
  • Access Implementors: _getListing, _getNames, _getEnabled
  • Mutators: __init__, enable, disable, _setEnabled
  • R/O Properties: listing, names, items
  • R/W Properties: enabled

Initialize the state variables of a derived class

Parameters:
  • items (dict) – dictionary of states
  • owner (ClassWithCollections) – object which owns the collection
  • name (basestring) – literal description. Usually just attribute name for the collection, e.g. ‘states’
disable(index)

Disable state variable defined by index id

enable(index, value=True, missingok=False)

Enable state variable given in index

enabled

Return list of enabled states

Parameters:
  • nondefault (bool) – Either to return also states which are enabled simply by default
  • invert (bool) – Would invert the meaning, ie would return disabled states
isActive(index)

Returns True if state index is known and is enabled

isEnabled(index)

Returns True if state index is enabled