af.model.hierarchies package¶
Submodules¶
af.model.hierarchies.BaseHierarchy module¶
-
class
af.model.hierarchies.BaseHierarchy.BaseHierarchy[source]¶ Bases:
objectClass that used as a model of Hierarchy. A hierarchy can be of a supression or generalization kind. The only difference between both kinds, is that the supression hierarchy transforms every value into the same supression value, and the generalization hierarchy transforms a value into the value that is one level up.
-
add_node(parent_node, leaf_node)[source]¶ Add a new node to the current hierarchy
Parameters: - parent_node – Node that acts as a parent of the node that is to be added to the hierarchy
- leaf_node – New node to add
-
create_supression_node()[source]¶ Creates the basic supression node to be used on every hierarchy. A supression node is a GLGNode that has ‘******‘ as a value, and no parent
Return type: Supression Node
-
find_node(node_value, starting_node=None)[source]¶ Given a node value, find it’s corresponding Node
Parameters: - node_value (string) – Value of the node
- starting_node – Node (None by default). Used for recursion and knowing where is the finding cursor located
Return type: Node with the node_value
-
get_all_nodes_complete_transformation()[source]¶ For all the leaf nodes, get their complete list of possible dimensions on the GLG Graph
Return type: List of tuples containing all the possible transformations
-
get_generalization_level_representation(starting_node, generalization_level)[source]¶ Given a node, transform it to a certain generalization level
Parameters: - starting_node – Instance of a Node.
- generalization_level (int) – Value of the level it is intended for the node to be generalized.
Return type: The starting node generalization.
-
get_hierarchy_depth()[source]¶ Returns the hierarchy depth (Height)
Return type: Hierarchy depth count
-
get_leaf_node(leaf_node_value)[source]¶ Given a value that supposedly belongs to a leaf node, find the node and return it.
Parameters: leaf_node_value (string) – Value of the node Return type: Node containing the leaf_node_value
-
get_node_depth(node)[source]¶ Given a node, get its depth; or in other words, how many levels it has upon him (including the root node)
Parameters: node – Node we want to check its depth Return type: Node depth count
-
hierarchy_representation(node=None)[source]¶ Returns the hierarchy representation in the form of a dictionary
Parameters: node – Node (Default None) Used for recursion levels. Return type: Dictionary representation of the hierarchy
-
maintain_leaf_nodes(node, action='add')[source]¶ Every time we add or remove a leaf node, the leaf node cache list has to be maintained.
Parameters: - node – Node we want to add/remove
- action (string) – Action we want to perform (add, remove)
-
populate_nodes(parent_node, nodes, attribute_type)[source]¶ This method is to be used every time a hierarchy is loaded, and the nodes are populated inside of it.
Parameters: - parent_node – Node indicating the current parent to which all the nodes are to be put below
- nodes (dict) – Dictionary containing all the information about the nodes, its values and son nodes.
- attribute_type – The type of the node value.
-
transform(data_value, lvl)[source]¶ Given a certain data value, and a level, look for it the node containing that value, and get the generalization level representation of the lvl
Parameters: - data_value (string) – Value of the Node
- lvl (int) – Level inteded to generalize the node
Return type: Value of the node that has been transformed to the generalization level.
-
af.model.hierarchies.Node module¶
-
class
af.model.hierarchies.Node.Node(value, parent=None, nodes=None)[source]¶ Bases:
objectClass node use in the hierarchies.
-
add_node(node)[source]¶ Add a new node as a son
Parameters: node – New node to be added into the nodes son list.
-
is_leaf()[source]¶ Checks if it is a leaf node or not, based on its leaf nodes
Return type: Boolean indicating if it is a leaf node or not.
-