Skip to content

Commit 84c6f7f

Browse files
author
Cameron Mattson
committed
Increased code DRYness
1 parent b4491c5 commit 84c6f7f

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

src/comparison_tools/PairwiseCompareManager.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from typing import Optional
22

33
import pandas as pd
4-
from comparators.Comparator import Comparator
54

5+
from comparators.Comparator import Comparator
66
from comparison_tools.PairwiseCompare import PairwiseCompare
77

88

@@ -61,27 +61,22 @@ def __init__(
6161
self._comparator = _comparator
6262

6363
if len(_different_columns) >= 2 and not _same_columns:
64-
pairwise_compare_obj = PairwiseCompare(
65-
_df=_df,
66-
_comparator=_comparator,
67-
_antehoc_group_cols=_different_columns[:1],
68-
_posthoc_group_cols=_different_columns[1:],
69-
_feat_cols=_feat_cols,
70-
_drop_cols=_drop_cols,
71-
)
64+
_same_columns = _different_columns[:1].copy()
65+
_different_columns = _different_columns[1:]
66+
67+
pairwise_compare_obj = PairwiseCompare(
68+
_df=_df,
69+
_comparator=_comparator,
70+
_antehoc_group_cols=_same_columns,
71+
_posthoc_group_cols=_different_columns,
72+
_feat_cols=_feat_cols,
73+
_drop_cols=_drop_cols,
74+
)
7275

76+
if len(_different_columns) >= 2 and not _same_columns:
7377
pairwise_compare_obj.inter_comparisons()
7478

7579
elif len(_different_columns) >= 1 and len(_same_columns) >= 1:
76-
pairwise_compare_obj = PairwiseCompare(
77-
_df=_df,
78-
_comparator=_comparator,
79-
_antehoc_group_cols=_same_columns,
80-
_posthoc_group_cols=_different_columns,
81-
_feat_cols=_feat_cols,
82-
_drop_cols=_drop_cols,
83-
)
84-
8580
pairwise_compare_obj.intra_comparisons()
8681

8782
def __call__(self):

0 commit comments

Comments
 (0)