Package mvpa :: Package misc :: Module state :: Class StateCollection
[hide private]
[frames] | no frames]

Class StateCollection

source code


Container of StateVariables for a stateful object.
Instance Methods [hide private]
 
_copy_states_(self, fromstate, deep=False)
Copy known here states from fromstate object into current object
source code
 
_changeTemporarily(self, enable_states=None, disable_states=None, other=None)
Temporarily enable/disable needed states for computation
source code
 
_resetEnabledTemporarily(self)
Reset to previousely stored set of enabled states
source code

Inherited from Collection: __getattribute__, __getitem__, __setattr__, __str__, add, getvalue, isSet, remove, reset, setvalue

Inherited from object: __delattr__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__

    Public Access Functions
 
isEnabled(self, index)
Returns True if state index is enabled
source code
 
isActive(self, index)
Returns True if state index is known and is enabled
source code

Inherited from Collection: isKnown

    Access Implementors
 
_getEnabled(self, nondefault=True, invert=False)
Return list of enabled states
source code

Inherited from Collection (private): _getListing, _getNames

    Mutators
 
__init__(self, items=None, owner=None)
Initialize the state variables of a derived class
source code
 
enable(self, index, value=True, missingok=False)
Enable state variable given in index
source code
 
disable(self, index)
Disable state variable defined by index id
source code
 
_setEnabled(self, indexlist)
Given indexlist make only those in the list enabled
source code
Class Variables [hide private]
    R/O Properties

Inherited from Collection: listing

Instance Variables [hide private]
  __storedTemporarily
List to contain sets of enabled states which were enabled temporarily.

Inherited from Collection (private): _items

Properties [hide private]

Inherited from Collection: owner

Inherited from object: __class__

    R/O Properties

Inherited from Collection: items, names

    R/W Properties
  enabled
Return list of enabled states
Method Details [hide private]

__init__(self, items=None, owner=None)
(Constructor)

source code 
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'
Overrides: object.__init__

_copy_states_(self, fromstate, deep=False)

source code 

Copy known here states from fromstate object into current object

Crafted to overcome a problem mentioned above in the comment and is to be called from __copy__ of derived classes

Probably sooner than later will get proper __getstate__, __setstate__

_changeTemporarily(self, enable_states=None, disable_states=None, other=None)

source code 

Temporarily enable/disable needed states for computation

Enable or disable states which are enabled in other and listed in enable _states. Use resetEnabledTemporarily to reset to previous state of enabled.

other can be a Stateful object or StateCollection

_getEnabled(self, nondefault=True, invert=False)

source code 
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

_setEnabled(self, indexlist)

source code 

Given indexlist make only those in the list enabled

It might be handy to store set of enabled states and then to restore it later on. It can be easily accomplished now:

>>> states_enabled = stateful.enabled
>>> stateful.enabled = ['blah']
>>> stateful.enabled = states_enabled

Property Details [hide private]

enabled

Return list of enabled states
Get Method:
_getEnabled(self, nondefault=True, invert=False) - Return list of enabled states
Set Method:
_setEnabled(self, indexlist) - Given indexlist make only those in the list enabled