Skip to content

Commit 1d18454

Browse files
authored
Merge pull request #27 from WayScience/fix_column_reference
Fix Column Reference
2 parents d2812c7 + 8cbb4b2 commit 1d18454

File tree

5 files changed

+38
-12
lines changed

5 files changed

+38
-12
lines changed

pyproject.toml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pairwise-compare"
3-
version = "0.1.1"
3+
version = "0.0.0"
44
description = "Allows the user to compare groups of data specified in a tidy pandas dataframe with ease."
55
authors = ["Cameron Mattson <mattsoncameron1@gmail.com>"]
66
license = "BSD 3-Clause"
@@ -28,6 +28,20 @@ matplotlib = "^3.9.2"
2828
pylint = "^3.3.1"
2929
notebook = "^7.2.2"
3030

31+
[tool.poetry.requires-plugins]
32+
poetry-dynamic-versioning = { version = ">=1.0.0,<2.0.0", extras = ["plugin"] }
33+
34+
[tool.poetry-dynamic-versioning]
35+
enable = true
36+
style = "pep440"
37+
vcs = "git"
38+
39+
[tool.poetry-dynamic-versioning.substitution]
40+
files = [
41+
"src/comparison_tools/__init__.py",
42+
"src/comparators/__init__.py"
43+
]
44+
3145
[build-system]
32-
requires = ["poetry-core"]
33-
build-backend = "poetry.core.masonry.api"
46+
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
47+
build-backend = "poetry_dynamic_versioning.backend"

src/comparators/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.0.0"

src/comparison_tools/PairwiseCompare.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ def __init__(
107107
_group_columns=self.__posthoc_group_cols,
108108
)
109109

110-
def __warn_empty_comparisons(self, _comparison_type_name):
110+
def __warn_empty_comparisons(self, _comparison_type_name: str):
111111

112112
warnings.warn(f"{_comparison_type_name} were empty", UserWarning)
113113

114-
def __is_iterable_with_strings(self, _data_structure):
114+
def __is_iterable_with_strings(self, _data_structure: Any):
115115

116116
prefix_msg = "Expected an Iterable of Strings."
117117

@@ -125,7 +125,7 @@ def __is_iterable_with_strings(self, _data_structure):
125125
if any(not isinstance(element, str) for element in _data_structure):
126126
raise TypeError(f"{prefix_msg} Data in Iterable is not of type String.")
127127

128-
def __get_group_column_idxs(self, _group_columns):
128+
def __get_group_column_idxs(self, _group_columns: list[str]):
129129
"""Get group fields after removing dropped columns."""
130130

131131
return [
@@ -145,11 +145,15 @@ def __get_group_column_element(
145145
else:
146146
return _group_column_data
147147

148-
def __contains_match(self, _groups):
148+
def __contains_match(
149+
self,
150+
_groups: Union[tuple[tuple[Any]], tuple[Any]],
151+
_group_columns: list[str],
152+
):
149153
"""Check if the same features between both groups are the same value."""
150154

151155
if not self.__one_different_comparison:
152-
if len(self.__posthoc_group_cols) == 1:
156+
if len(_group_columns) == 1:
153157
if _groups[0] == _groups[1]:
154158
return True
155159

@@ -176,7 +180,9 @@ def inter_comparisons(self):
176180
# Iterate through each ante group combination
177181
for apair in apairs:
178182

179-
if self.__contains_match(apair):
183+
# Don't make a comparison if with this pair if
184+
# any of the corresponding column values match
185+
if self.__contains_match(apair, self.__antehoc_group_cols):
180186
continue
181187

182188
apair = tuple(
@@ -212,7 +218,9 @@ def inter_comparisons(self):
212218
# Iterate through each well group cartesian product and save the data
213219
for ppair in comparison_key_product:
214220

215-
if self.__contains_match(ppair):
221+
# Don't make a comparison if with this pair if
222+
# any of the corresponding column values match
223+
if self.__contains_match(ppair, self.__posthoc_group_cols):
216224
continue
217225

218226
ppair = tuple(
@@ -292,7 +300,9 @@ def intra_comparisons(self):
292300
# Iterate through the combinations pairs of the groups
293301
for ppair in comparison_key_combinations:
294302

295-
if self.__contains_match(ppair):
303+
# Don't make a comparison if with this pair if
304+
# any of the corresponding column values match
305+
if self.__contains_match(ppair, self.__posthoc_group_cols):
296306
continue
297307

298308
ppair = tuple(

src/comparison_tools/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.0.0"

tests/test_correctness_pairwise_compare_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_data(request):
5555
{
5656
"_comparator": PearsonsCorrelation(),
5757
"_same_columns": None,
58-
"_different_columns": ["Metadata_siRNA", "Metadata_Well"],
58+
"_different_columns": ["Metadata_siRNA", "Metadata_Well", "Metadata_genotype"],
5959
"_drop_cols": None,
6060
}
6161
),

0 commit comments

Comments
 (0)