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