compare_hierarchies.py

compare_hierarchies.py#

aviary.utils.compare_hierarchies.compare_hierarchies_to_merge(hierarchies_to_merge)[source]

Compares variable hierarchies to ensure there are no string-valued variable conflicts.

For all the variable hierarchies provided in hierarchies_to_merge this function compares each hierarchy with every other hierarchy as well as the Aviary core aircraft and mission hierarchies to ensure there are no string-valued variable conflicts within the same class or inner class to and infinite depth.

Parameters:

hierarchies_to_merge (list of classes) – This is a list of variable hierarchy classes which will be compared for merge compatibility with one another.

Return type:

None

Raises:

No explicit exceptions are raised by this function, although called functions may raise exceptions.

aviary.utils.compare_hierarchies.compare_inner_classes(class1, class2, show_all=False)[source]

Compare two nested class hierarchies and return a set of shared inner-classes.

Summary: This function takes in two classes that both are part of variable hierarchies and may contain inner-classes or variables with string-named values. This function compares those two classes and returns a set of inner classes that have the same name in both inputted classes. It will throw an error if the two classes have the same variable with a different string-named value.

Parameters:
  • class1 (class) – A class that is all or part of a variable hierarchy. This can be the top-level class in the hierarchy, or any inner class nested at any depth within that top-level class.

  • class2 (class) – A class that is all or part of a variable hierarchy. This can be the top-level class in the hierarchy, or any inner class nested at any depth within that top-level class.

  • show_all (bool, optional) – Flag to tell the function to return the sets of variables and inner classes for each provided class.

Returns:

  • overlapping_inner_classes (set of strings) – A set of string names of all the inner classes which are common between the two input classes.

  • class1_vars_set (set of strings, optional) – Set of string names of the variables belonging to class1, optional return based on show_all flag.

  • class2_vars_set (set of strings, optional) – Set of string names of the variables belonging to class2, optional return based on show_all flag.

  • class1_inner_classes_set (set of strings, optional) – Set of the string names of inner classes belonging to class1, optional return based on show_all flag.

  • class2_inner_classes_set (set of strings, optional) – Set of the string names of inner classes belonging to class2, optional return based on show_all flag.

Raises:

ValueError – If the two input classes both have a variable with the same variable name but different string-named value.

aviary.utils.compare_hierarchies.recursive_comparison(overlapping_inner_classes, outer_class_a, outer_class_b)[source]

Recursively compares all inner classes to an infinite depth and identifies mismatched string-named values.

For all of the inner class names provided in overlapping_inner_classes this function calls compare_inner_classes and compares those inner classes recursively until it reaches the full depth to which outer_class_a and outer_class_b have any inner classes in common.

Parameters:
  • overlapping_inner_classes (set of strings) – This is a set of strings where each string is the name of an inner class that outer_class_a and outer_class_b have in common.

  • outer_class_a (class) – A class that is all or part of a variable hierarchy. This can be the top-level class in the hierarchy, or any inner class nested at any depth within that top-level class.

  • outer_class_b (class) – A class that is all or part of a variable hierarchy. This can be the top-level class in the hierarchy, or any inner class nested at any depth within that top-level class.

Returns:

  • None

  • Exceptions

  • ———-

  • No exceptions explicitly raised by this function, although called functions may raise exceptions.