Table Of Contents

Previous topic

mvpa.misc.plot.topo

Next topic

mvpa.misc.stats

This Page

Quick search

mvpa.misc.state

Classes to control and store state information.

It was devised to provide conditional storage

The comprehensive API documentation for this module, including all technical details, is available in the Epydoc-generated API reference for mvpa.misc.state (for developers).

Classes

AttributeWithUnique

class mvpa.misc.state.AttributeWithUnique(name=None, hasunique=True, doc='Attribute with unique')

Bases: mvpa.misc.state.CollectableAttribute

Container which also takes care about recomputing unique values

XXX may be we could better link original attribute to additional attribute which actually stores the values (and do reverse there as well).

Pros:
  • don’t need to mess with getattr since it would become just another attribute
Cons:
  • might be worse design in terms of comprehension
  • take care about _set, since we shouldn’t allow change it externally

For now lets do it within a single class and tune up getattr

hasunique
reset()
uniqueValues

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the AttributeWithUnique documentation.

Full API documentation of AttributeWithUnique in module mvpa.misc.state.

AttributesCollector

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

Bases: type

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

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the AttributesCollector documentation.

Full API documentation of AttributesCollector in module mvpa.misc.state.

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()

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the ClassWithCollections documentation.

Full API documentation of ClassWithCollections in module mvpa.misc.state.

CollectableAttribute

class mvpa.misc.state.CollectableAttribute(name=None, doc=None)

Bases: object

Base class for any custom behaving attribute intended to become part of a collection.

Derived classes will have specific semantics:

  • StateVariable: conditional storage
  • AttributeWithUnique: easy access to a set of unique values within a container
  • Parameter: attribute with validity ranges.
    • ClassifierParameter: specialization to become a part of Classifier’s params collection
    • KernelParameter: –//– to become a part of Kernel Classifier’s kernel_params collection

Those CollectableAttributes are to be groupped into corresponding collections for each class by statecollector metaclass, ie it would be done on a class creation (ie not per each object)

isSet
name
reset()
Simply reset the flag
value

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the CollectableAttribute documentation.

Full API documentation of CollectableAttribute in module mvpa.misc.state.

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.

getvalue(index)
Returns the value by index
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

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

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
setvalue(index, value)
Sets the value by index
whichSet()
Return list of indexes which were set

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the Collection documentation.

Full API documentation of Collection in module mvpa.misc.state.

DatasetAttribute

class mvpa.misc.state.DatasetAttribute(name=None, hasunique=True, doc='Attribute with unique')
Bases: mvpa.misc.state.AttributeWithUnique

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the DatasetAttribute documentation.

Full API documentation of DatasetAttribute in module mvpa.misc.state.

FeatureAttribute

class mvpa.misc.state.FeatureAttribute(name=None, hasunique=True, doc='Attribute with unique')
Bases: mvpa.misc.state.AttributeWithUnique

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the FeatureAttribute documentation.

Full API documentation of FeatureAttribute in module mvpa.misc.state.

Harvestable

class mvpa.misc.state.Harvestable(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).

Initialize state of harvestable

Parameters:
  • 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
harvest_attribs

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the Harvestable documentation.

Full API documentation of Harvestable in module mvpa.misc.state.

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

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the ParameterCollection documentation.

Full API documentation of ParameterCollection in module mvpa.misc.state.

SampleAttribute

class mvpa.misc.state.SampleAttribute(name=None, hasunique=True, doc='Attribute with unique')
Bases: mvpa.misc.state.AttributeWithUnique

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the SampleAttribute documentation.

Full API documentation of SampleAttribute in module mvpa.misc.state.

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’)

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the SampleAttributesCollection documentation.

Full API documentation of SampleAttributesCollection in module mvpa.misc.state.

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 (Stateful) – 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

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the StateCollection documentation.

Full API documentation of StateCollection in module mvpa.misc.state.

StateVariable

class mvpa.misc.state.StateVariable(name=None, enabled=True, doc='State variable')

Bases: mvpa.misc.state.CollectableAttribute

Simple container intended to conditionally store the value

enable(value=False)
isEnabled
reset()
Simply detach the value, and reset the flag

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the StateVariable documentation.

Full API documentation of StateVariable in module mvpa.misc.state.