Skip to content

Commit ae1afd3

Browse files
committed
reg: filters not applied in final plots since 2.25.1
1 parent dc97819 commit ae1afd3

3 files changed

Lines changed: 125 additions & 2 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
2.26.2
2+
- reg: filters not applied in final plots since 2.25.1
23
- fix: prevent `pipeline.lock` deadlocks via Qt signal cluttering
34
- fix: update axes ranges when "Auto XY-range" is selected in plotting
45
- enh: increase default disk store size from 2GB to 9GB

dcscope/pipeline/filter_ray.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ def get_final_child(self, rtdc_ds=None, filters=None, apply_filter=True):
101101
# past self
102102

103103
filters = [f for f in filters if f.filter_used]
104+
if self.segments:
105+
# Make sure that the segments are trimmed to the amount of
106+
# filters in the filter ray.
107+
self.segments = self.segments[:len(filters)]
108+
if self.segments:
109+
# Make sure that the final dataset in the segments does not
110+
# have any filters applied.
111+
self.segments[-1][2].reset_filter()
104112

105113
if filters:
106114
# apply all filters
@@ -126,11 +134,11 @@ def get_final_child(self, rtdc_ds=None, filters=None, apply_filter=True):
126134
final_ds = ds
127135
else:
128136
final_ds = ds
129-
130-
if not external_ds:
137+
# make sure no filters are applied to the returned dataset
131138
ds.reset_filter()
132139

133140
if apply_filter:
141+
# Apply all filters in the underlying hierarchy.
134142
final_ds.apply_filter()
135143

136144
return final_ds
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import pathlib
2+
3+
from dcscope import pipeline
4+
5+
6+
def test_filtering_change_get_dataset():
7+
path = pathlib.Path(__file__).parent / "data" / "calibration_beads_47.rtdc"
8+
9+
# initialize
10+
slot = pipeline.Dataslot(path)
11+
ds = slot.get_dataset()
12+
assert len(ds) == 47
13+
ray = pipeline.FilterRay(slot)
14+
15+
filt1 = pipeline.Filter()
16+
filt1.limit_events = [True, 4]
17+
18+
ray.set_filters([filt1])
19+
ds1 = ray.get_dataset()
20+
assert len(ds1) == 4
21+
22+
filt1.limit_events = [False, 4]
23+
ds2 = ray.get_dataset()
24+
assert len(ds2) == 47
25+
26+
filt1.limit_events = [True, 4]
27+
ds3 = ray.get_dataset()
28+
assert len(ds3) == 4
29+
30+
filt1.limit_events = [False, 4]
31+
ds4 = ray.get_dataset()
32+
assert len(ds4) == 47
33+
34+
35+
def test_filtering_change_get_final_child():
36+
path = pathlib.Path(__file__).parent / "data" / "calibration_beads_47.rtdc"
37+
38+
# initialize
39+
slot = pipeline.Dataslot(path)
40+
ds = slot.get_dataset()
41+
assert len(ds) == 47
42+
ray = pipeline.FilterRay(slot)
43+
44+
filt1 = pipeline.Filter()
45+
filt1.limit_events = [True, 4]
46+
47+
ray.set_filters([filt1])
48+
ds1 = ray.get_final_child()
49+
assert len(ds1) == 4
50+
51+
filt1.limit_events = [False, 4]
52+
ds2 = ray.get_final_child()
53+
assert len(ds2) == 47
54+
55+
filt1.limit_events = [True, 4]
56+
ds3 = ray.get_final_child()
57+
assert len(ds3) == 4
58+
59+
filt1.limit_events = [False, 4]
60+
ds4 = ray.get_final_child()
61+
assert len(ds4) == 47
62+
63+
64+
def test_filtering_change_with_pipeline():
65+
path = pathlib.Path(__file__).parent / "data" / "calibration_beads_47.rtdc"
66+
67+
# initialize
68+
pipe = pipeline.Pipeline()
69+
pipe.add_slot(path=path)
70+
filt1 = pipeline.Filter()
71+
pipe.add_filter(filt1)
72+
ds = pipe.get_dataset(0)
73+
assert len(ds) == 47
74+
75+
slot_id = pipe.slot_ids[0]
76+
filt_id = filt1.identifier
77+
78+
pipe.set_element_active(slot_id, filt_id, True)
79+
80+
assert pipe.filter_ids == [filt_id]
81+
filters = pipe.get_filters_for_slot(slot_id=slot_id,
82+
max_filter_index=-1)
83+
assert filters[0] == filt1
84+
85+
filt1.limit_events = [True, 4]
86+
87+
assert pipe.element_states[slot_id][filt_id]
88+
assert pipe.get_filters_for_slot(slot_id=slot_id,
89+
max_filter_index=-1) == [filt1]
90+
ds1 = pipe.get_dataset(0)
91+
assert len(ds1) == 4
92+
93+
pipe.set_element_active(slot_id, filt_id, False)
94+
assert not pipe.element_states[slot_id][filt_id]
95+
assert pipe.get_filters_for_slot(slot_id=slot_id,
96+
max_filter_index=-1) == []
97+
ds2 = pipe.get_dataset(0)
98+
assert len(ds2) == 47
99+
100+
pipe.set_element_active(slot_id, filt_id, True)
101+
assert pipe.element_states[slot_id][filt_id]
102+
assert len(pipe.filters) == 1
103+
assert pipe.get_filters_for_slot(slot_id=slot_id,
104+
max_filter_index=-1) == [filt1]
105+
ray = pipe.get_ray(slot_id)
106+
ray.set_filters([filt1])
107+
ds3a = ray.get_dataset()
108+
assert len(ds3a) == 4
109+
ds3b = pipe.get_dataset(0)
110+
assert len(ds3b) == 4
111+
112+
pipe.set_element_active(slot_id, filt_id, False)
113+
ds4 = pipe.get_dataset(0)
114+
assert len(ds4) == 47

0 commit comments

Comments
 (0)