Skip to content

Commit 535576c

Browse files
committed
change fraction_filter's behaviour
1 parent e48c04c commit 535576c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

dimspy/process/peak_filters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ def filter_fraction(pm, fraction_threshold, within_classes=False, class_tag_type
138138
raise KeyError('must provide class tag type for within classes filtering')
139139
if not all(map(lambda t: t.has_tag_type(class_tag_type), pm.peaklist_tags)):
140140
raise AttributeError('not all tags have tag type [%s]' % class_tag_type)
141-
flg = np.ones(pm.shape[1])
141+
flg = np.zeros(pm.shape[1])
142142
for tag in pm.tags_of(class_tag_type):
143143
with unmask_peakmatrix(pm, tag) as m:
144-
flg = np.logical_and(flg, (m.fraction >= fraction_threshold))
144+
flg = np.logical_or(flg, (m.fraction >= fraction_threshold))
145145
pm.add_flag(flag_name, flg)
146146
return pm
147147

tests/test_peak_filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_peak_matrix_fraction_filter(self):
111111
pm._attr_dict[attr][:,2] *= [1, 1, 1, 1, 1, 1, 0, 0]
112112

113113
pm = filter_fraction(pm, 0.6, within_classes = True, class_tag_type = 'plate')
114-
self.assertEqual(pm.shape[1], 9)
114+
self.assertEqual(pm.shape[1], 10)
115115
self.assertRaises(AttributeError, lambda: filter_fraction(pm, 1, within_classes = True, class_tag_type = 'time_point'))
116116
self.assertRaises(KeyError, lambda: filter_fraction(pm, 1, within_classes = True))
117117

0 commit comments

Comments
 (0)