From ddbdf84d6f04761815e349947612f435f55e31df Mon Sep 17 00:00:00 2001 From: kkaris Date: Thu, 5 Dec 2024 13:54:16 -0700 Subject: [PATCH] Add option to flip the longest axis to rows for more readable layout --- mira/metamodel/comparison.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mira/metamodel/comparison.py b/mira/metamodel/comparison.py index 39eef0d72..f56bae612 100644 --- a/mira/metamodel/comparison.py +++ b/mira/metamodel/comparison.py @@ -879,6 +879,7 @@ def get_concept_comparison_table( refinement_func: Callable[[str, str], bool] = None, keep_unmatched: bool = False, use_full_name: bool = True, + longest_on_rows: bool = False, ) -> pd.DataFrame: """Compare two template models by their concepts and return a table @@ -896,6 +897,8 @@ def get_concept_comparison_table( use_full_name : Use the full name, including top curie and context (if available), of the concepts in the table. Default: True. If False, use one of display name or name. + longest_on_rows : + If True, switch the longest axis to the rows. Default: False. Returns ------- @@ -946,4 +949,9 @@ def _get_name_from_concept(concept: Concept) -> str: data[name1][name2] = "" table = pd.DataFrame(data) table.fillna("", inplace=True) + + # Transpose if len(rows) < len(columns) + if longest_on_rows and table.shape[0] < table.shape[1]: + table = table.T + return table