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

Class Collection

source code


Container of some CollectableAttributes.
Instance Methods [hide private]
 
__init__(self, items=None, owner=None, name=None)
Initialize the Collection
source code
 
_setName(self, name) source code
 
__str__(self)
str(x)
source code
 
_cls_repr(self)
Collection specific part of __repr__ for a class containing it, ie a part of __repr__ for the owner object
source code
 
_is_initializable(self, index)
Checks if index could be assigned within collection via _initialize
source code
 
_initialize(self, index, value)
Initialize index (no check performed) with value
source code
 
__repr__(self)
repr(x)
source code
 
isKnown(self, index)
Returns True if state index is known at all
source code
 
isSet(self, index=None)
If item (or any in the present or listed) was set
source code
 
whichSet(self)
Return list of indexes which were set
source code
 
_checkIndex(self, index)
Verify that given index is a known/registered state.
source code
 
add(self, item)
Add a new CollectableAttribute to the collection
source code
 
remove(self, index)
Remove item from the collection
source code
 
__getattribute__(self, index)
x.__getattribute__('name') <==> x.name
source code
 
__setattr__(self, index, value)
x.__setattr__('name', value) <==> x.name = value
source code
 
__getitem__(self, index) source code
 
get(self, index, default)
Access the value by a given index.
source code
 
_action(self, index, func, missingok=False, **kwargs)
Run specific func either on a single item or on all of them
source code
 
reset(self, index=None)
Reset the state variable defined by index
source code
 
_getListing(self)
Return a list of registered states along with the documentation
source code
 
_getNames(self)
Return ids for all registered state variables
source code
 
_getOwner(self) source code
 
_setOwner(self, owner) source code
 
_updateOwner(self, index=None, register=True)
Define an entry within owner's __dict__ so ipython could easily complete it
source code

Inherited from object: __delattr__, __format__, __hash__, __new__, __reduce__, __reduce_ex__, __sizeof__, __subclasshook__

Class Variables [hide private]
  names = property(fget= _getNames)
  items = property(fget= lambda x: x._items)
  owner = property(fget= _getOwner, fset= _setOwner)
  name = property(fget= lambda x: x.__name, fset= _setName)
  listing = VProperty(fget= _getListing)
Instance Variables [hide private]
  _items
Dictionary to contain registered states as keys and values signal either they are enabled
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

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

__str__(self)
(Informal representation operator)

source code 
str(x)
Overrides: object.__str__
(inherited documentation)

_cls_repr(self)

source code 
Collection specific part of __repr__ for a class containing it, ie a part of __repr__ for the owner object
Returns:
list of items to be appended within __repr__ after a .join()

_is_initializable(self, index)

source code 

Checks if index could be assigned within collection via _initialize

It is to facilitate dynamic assignment of collections' items within derived classes' __init__ depending on the present collections in the class.

Returns:
bool value for a given index

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)

isSet(self, index=None)

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

_checkIndex(self, index)

source code 
Verify that given index is a known/registered state.
Raises:
  • KeyError - if given index is not known

add(self, item)

source code 

Add a new CollectableAttribute to the collection

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__

Parameters:
  • item (CollectableAttribute) - or of derived class. Must have 'name' assigned

__getattribute__(self, index)

source code 
x.__getattribute__('name') <==> x.name
Overrides: object.__getattribute__

__setattr__(self, index, value)

source code 
x.__setattr__('name', value) <==> x.name = value
Overrides: object.__setattr__
(inherited documentation)

get(self, index, default)

source code 

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.

_action(self, index, func, missingok=False, **kwargs)

source code 
Run specific func either on a single item or on all of them
Parameters:
  • index (basestr) - Name of the state variable
  • func - Function (not bound) to call given an item, and **kwargs
  • missingok (bool) - If True - do not complain about wrong index

_updateOwner(self, index=None, register=True)

source code 

Define an entry within owner's __dict__ so ipython could easily complete it

XXX Needs refactoring since we duplicate the logic of expansion of index value

Parameters:
  • index (basestring or list of basestring) - Name of the attribute. If None -- all known get registered
  • register (bool) - Register if True or unregister if False