Skip to content

Commit 83d28a2

Browse files
committed
add test for FCS file with zero gain
1 parent 9ae6542 commit 83d28a2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
12.9 MB
Binary file not shown.

tests/test_flowdata.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ def test_as_array_with_preprocessing_with_empty_timestep():
7272

7373
np.testing.assert_array_equal(events_orig[:, time_index], events_preproc[:, time_index])
7474

75+
@staticmethod
76+
def test_as_array_with_preprocessing_with_zero_gain():
77+
# If FCS have PnG (gain) values of 0, they should be treated
78+
# as having a gain of 1.0 (i.e. no gain). If the 0 gain was
79+
# allowed it would result in divide by zero warnings and
80+
# incorrect pre-processed event data.
81+
flow_data = FlowData('data/fcs_files/zero_gain/M0_WM278_S1.fcs')
82+
83+
# Get both unprocessed and preprocessed to compare channel events.
84+
# Since there's zero gain, the events should be the same
85+
events_orig = flow_data.as_array(preprocess=False)
86+
events_preproc = flow_data.as_array(preprocess=True)
87+
88+
# first test that there are no np.inf or np.nan values,
89+
# then test the raw and pre-processed arrays are equal.
90+
np.testing.assert_equal(np.sum(np.isinf(events_preproc)), 0)
91+
np.testing.assert_equal(np.sum(np.isnan(events_preproc)), 0)
92+
np.testing.assert_array_equal(events_orig, events_preproc)
93+
7594
@staticmethod
7695
def test_as_array_no_preprocessing():
7796
# 'data1.fcs' has some channels with non 1.0 gain and some stored as non-linear

0 commit comments

Comments
 (0)