Package schrodinger :: Package application :: Package combiglide :: Package packages :: Module hierarchy :: Class Hierarchy
[hide private]
[frames] | no frames]

Class Hierarchy

Class that stores the structure of the hierarchy.

Instance Methods [hide private]
 
__init__(self, name, partitioning_names_at_levels)
Create the partitioning network.
Partition
getLowestCommonPartition(self, items)
Given a collection of items, find the lowest common partition in the hierarchy.
 
setPartitionPopulations(self)
Calculate and store the number of items in each partition in the hierarchy.
list of str
getOrderedPartitioningNames(self)
Returns: List of partitioning names in order required by registerItem().
Partition
registerItem(self, ordered_partition_names, data=None)
Add an item to the hierarchy.
list of Partitioning
_createOrderedPartitioningsAtLevel(self, ilevel, partitioning_names)
Create partitionings at level ilevel and add them to self.ordered_partitionings.
 
_createOrderedPartitionings(self, partitioning_names_at_levels)
Create partitionings and self.ordered_partitionings list.
 
_addPartitionRelatives(self, ordered_partitions)
Add parents and children to the partitions of a newly registered item.
list of list of Partition
_getPartitionesAtLevels(self, ordered_partitions)
Given a flat list of partitions, return a list of lists containing the same partitions in sub-lists corresponding to the levels of the schme.
Static Methods [hide private]
 
_checkCardinalityOfLevels(partitioning_names_at_levels)
Make sure first and last level have only a single partitioning:
 
_addPartitionRelativesAtLevel(partitions, children, parents)
Add the specified children and parents to the specified partitions.
 
_addPartitioningRelatives(partitionings_at_levels)
Add parents and children to all partitionings at all levels.
 
_addPartitioningRelativesAtLevel(partitioning_l, child_l, parent_l)
Add parents and children to all partitionings at one level.
Instance Variables [hide private]
Set of Partitioning _partitioning_names
Set of partitioning names, for uniqueness checking
List of list of Partitioning _partitionings_at_levels
List of list of partitionings, each outer list corresponding to a level
Partitioning _root
The root partitioning
str name
Name of this Hierarchy (set by Hierarchy.__init__())
int nlevel
Number of levels in this Hierarchy (set by Hierarchy.__init__())
List of Partitioning ordered_partitionings
List of partitionings in a canonical order, starting with partitionings at the 0th level
Method Details [hide private]

__init__(self, name, partitioning_names_at_levels)
(Constructor)

 

Create the partitioning network. The network is completely defined by the input parameter partitioning_names_at_levels.

Parameters:
  • name (str) - name of this hierarchy
  • partitioning_names_at_levels (list of list of str) - partitioning names at all levels. The network that appears in the module docstring would be created by providing the value [ ['0'], ['1a','1b'], ['2'], ['3'] ].

    The indices of the sub-arrays in the top-level array correspond to the levels of the hierarchy. Thus, in this example, level 0 contains partitioning '0', level 1 contains partitionings '1a' and '1b", and so on.

getLowestCommonPartition(self, items)

 

Given a collection of items, find the lowest common partition in the hierarchy.

Parameters:
  • items (list, tuple or set) - Collection of items (partitions at level 0)
Returns: Partition
Lowest common partition

setPartitionPopulations(self)

 

Calculate and store the number of items in each partition in the hierarchy. This should be called by the application after all items have been registered.

getOrderedPartitioningNames(self)

 
Returns: list of str
List of partitioning names in order required by registerItem().

registerItem(self, ordered_partition_names, data=None)

 

Add an item to the hierarchy.

Parameters:
  • ordered_partition_names (list of str) - List of item's partition names in the canonical partitioning order. This is the order in which the corresponding partitioning names appear in the unrolled partitioning_names_at_levels parameter supplied to the __init__() function. For the hierarchy shown in the module-level docstring, a value might look like [ 'a', 'b', 'c', 'd', 'e' ], where the entries are the item's partition names in partitionings 0, 1a, 1b, 2 and 3, respectively.
  • data (anything) - Any data the user wishes to store with the item for later retrieval.
Returns: Partition
level-0 partition of the item

_createOrderedPartitioningsAtLevel(self, ilevel, partitioning_names)

 

Create partitionings at level ilevel and add them to self.ordered_partitionings.

Parameters:
  • ilevel (int) - Level at which these partitionings are to be added.
  • partitioning_names (list of str) - Names of partitionings to be created
Returns: list of Partitioning
List of partitionings created

_createOrderedPartitionings(self, partitioning_names_at_levels)

 

Create partitionings and self.ordered_partitionings list.

Parameters:
  • partitioning_names_at_levels (list of list of str) - partitioning names at all levels. Partitioning names must be unique.

_checkCardinalityOfLevels(partitioning_names_at_levels)
Static Method

 

Make sure first and last level have only a single partitioning:

Parameters:
  • partitioning_names_at_levels (list of list of str) - Partitioning names at each level

_addPartitionRelatives(self, ordered_partitions)

 

Add parents and children to the partitions of a newly registered item.

Parameters:
  • ordered_partitions (list of Partition) - List of partitions for a newly registered item, which must be in 1:1 correspondence with self.ordered_partitionings.

_addPartitionRelativesAtLevel(partitions, children, parents)
Static Method

 

Add the specified children and parents to the specified partitions.

Parameters:
  • partitions (list of Partition) - List of partitions whose relatives are to be added
  • children (list of Partition) - List of children of the partitions in partitions[]
  • parents (list of Partition) - List of parents of the partitions in partitions[]

_getPartitionesAtLevels(self, ordered_partitions)

 

Given a flat list of partitions, return a list of lists containing the same partitions in sub-lists corresponding to the levels of the schme.

Parameters:
  • ordered_partitions (list of Partition) - List of partitions, one for each partitioning in self.ordered_partitionings
Returns: list of list of Partition
List of lists; list[i] is a list of partitions at level i.

_addPartitioningRelatives(partitionings_at_levels)
Static Method

 

Add parents and children to all partitionings at all levels.

Parameters:
  • partitionings_at_levels (list of list of Partitioning) - at each level, a list of partitionings

_addPartitioningRelativesAtLevel(partitioning_l, child_l, parent_l)
Static Method

 

Add parents and children to all partitionings at one level.

Parameters:
  • partitioning_l (list of Partitioning) - a list of Partitionings at the level in question
  • child_l (list of Partitioning) - a list of children of the Partitionings in partitioning_l
  • parent_l (list of Partitioning) - a list of parents of the Partitionings in partitioning_l