Package schrodinger :: Package application :: Package combiglide :: Package packages :: Module classification_scheme :: Class Class_
[hide private]
[frames] | no frames]

Class Class_

A Class in the classification scheme. Meant to be called only by Node in this module. N.B.: The term "item" is a synonym for a Class_ object at the lowest level of the hierarchy.

Instance Methods [hide private]
 
__init__(self, node, name, data=None)
Create a new class with the given name in the given node.
 
addOrderedClasses(self, ordered_classes)
Add the ordered class list to its item.
 
addChild(self, child)
Add a child to the current class.
 
addParent(self, parent)
Add a parent to the current class.
 
getItems(self, add_pop=False)
Get the set of items contained in the current class.
set of items
getRandomItems(self, nwanted)
Get (up to) nwanted random items from the current class.
set of items
_getDiverseRandomItemsRecurs(self, nwanted, fill)
Worker function to implement the recursive part of the method invoked by getDiverseRandomItems.
set of items
getDiverseRandomItems(self, nwanted, fill=1)
Get (up to) nwanted random items from a Class_, selecting more or less equally from Class_ children, recursively, at each level down to the items themselves.
 
__str__(self)
Class Variables [hide private]
int NO_FILL = 0
Do not diverge from equal child sampling in an attempt to return nwanted items; see getDiverseRandomItems().
int PART_FILL = 1
Mildly diverge from equal child sampling in an attempt to return nwanted items; see getDiverseRandomItems().
int FULL_FILL = 2
Strongly diverge from equal child sampling in an attempt to return nwanted items; see getDiverseRandomItems().
Instance Variables [hide private]
set of Class_ children
Children of the current Class_ (set by Scheme.registerItem())
Any object data
Arbitrary data associated with an item (set by Scheme.registerItem())
str name
Name of the current Class_ (set by Scheme.registerItem())
int nitems
Number of items contained by the current Class_ (set by Scheme.setClassPopulations())
Node node
Node to which the current Class_ belongs (set by Scheme.registerItem())
list of Class_ ordered_classes
for the lowest-level Node, only, the full ordered class list for an item.
set of Class_ parents
Parents of the current Class_ (set by Scheme.registerItem())
Method Details [hide private]

__init__(self, node, name, data=None)
(Constructor)

 

Create a new class with the given name in the given node. It is assumed that the name has already been checked for uniqueness within the node.

Parameters:
  • node (Node) - Node to which the class is added.
  • name (str) - Class name.
  • data (anything) - Any object the user wishes to store with the item for later retrieval.

addOrderedClasses(self, ordered_classes)

 

Add the ordered class list to its item. This permits certain search optimizations.

Parameters:
  • ordered_classes (list of Class_) - The item's ordered class list for all nodes

addChild(self, child)

 

Add a child to the current class.

Parameters:
  • child (Class_) - The child class to be added to the current class's children.

addParent(self, parent)

 

Add a parent to the current class.

Parameters:
  • parent (Class_) - The parent class to be added to the current class's parents.

getItems(self, add_pop=False)

 

Get the set of items contained in the current class.

Parameters:
  • add_pop (bool) - If True, set the class attribute "nitems" to the number of items in each class encountered.

getRandomItems(self, nwanted)

 

Get (up to) nwanted random items from the current class. If there are nwanted or fewer items in the class, return them all.

Parameters:
  • nwanted (int) - Maximum number of items to return.
Returns: set of items
Items constituting the sample

_getDiverseRandomItemsRecurs(self, nwanted, fill)

 

Worker function to implement the recursive part of the method invoked by getDiverseRandomItems. See that method's description for details.

Parameters:
  • nwanted (int) - Maximum number of items to return
  • fill (Class_ constant) - One of FULL_FILL, PART_FILL, or NO_FILL, which enforce successively stronger diversity criteria
Returns: set of items
Items constituting the sample

getDiverseRandomItems(self, nwanted, fill=1)

 

Get (up to) nwanted random items from a Class_, selecting more or less equally from Class_ children, recursively, at each level down to the items themselves. This avoids unbalanced random sampling in situations where some child classes contain many more items than others.

Parameters:
  • nwanted (int) - Maximum number of items to be requrned
  • fill (Class_ constant) - One of FULL_FILL, PART_FILL, or NO_FILL, which enforce successively stronger diversity criteria and lead to successively lower likelihood that a full complement of nwanted structures will be returned. PART_FILL is the default. With FULL_FILL, the method will always return a full complement of nwanted items, if that many exist.
Returns: set of items
Items constituting the sample