Skip to content

Commit e68ea7b

Browse files
committed
Fixing filter_fraction
1 parent 61624c3 commit e68ea7b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

dimspy/models/peaklist_tags.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ def has_tag_type(self, tag_type):
9090
"""
9191
Checks whether there exists a specific tag type.
9292
93-
:param tag_type: the tag type for checking
93+
:param tag_type: the tag type for checking, None tag_type (i.e. untyped) always return True
9494
:rtype: bool
9595
9696
"""
97-
return tag_type in self.tag_types
97+
return tag_type is None or tag_type in self.tag_types
9898

9999
def has_tag(self, *args, **kwargs):
100100
"""

dimspy/process/peak_filters.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def filter_fraction(pm, fraction_threshold, within_classes=False, class_tag_type
120120
:param pm: the target peak matrix
121121
:param fraction_threshold: threshold of the sample fractions
122122
:param within_classes: whether to calculate the fraction array within each class. Default = False
123-
:param class_tag_type: tag type to unmask samples within the same class. Default = None, indicating untyped tags
123+
:param class_tag_type: tag type to unmask samples within the same class. Default = None
124124
:param flag_name: name of the new flag. Default = 'fraction_flag'
125125
:rtype: PeakMatrix object
126126
@@ -131,6 +131,8 @@ def filter_fraction(pm, fraction_threshold, within_classes=False, class_tag_type
131131
if not within_classes:
132132
pm.add_flag(flag_name, pm.fraction >= fraction_threshold)
133133
else:
134+
if class_tag_type is None:
135+
raise KeyError('must provide class tag type for within classes filtering')
134136
if not all(map(lambda t: t.has_tag_type(class_tag_type), pm.peaklist_tags)):
135137
raise AttributeError('not all tags have tag type [%s]' % class_tag_type)
136138
flg = np.ones(pm.shape[1])

0 commit comments

Comments
 (0)