@@ -115,6 +115,36 @@ def test_write_fcs(self):
115115 self .assertIsInstance (fcs_export , FlowData )
116116 os .unlink (file_name )
117117
118+ def test_write_fcs_from_non_f_datatype_file (self ):
119+ # load FCS file that has non-F datatypes
120+ flow_data = FlowData ('data/fcs_files/data1.fcs' )
121+
122+ # get preprocessed event array to serve as ground truth
123+ orig_proc_events = flow_data .as_array (preprocess = True )
124+
125+ # write out new FCS file
126+ # this will force preprocessing and the resulting FCS file will
127+ # have 'F' data type.
128+ tmp_flow_data_out_filename = 'tmp_flowdata_from_non_f_datatype.fcs'
129+ flow_data .write_fcs (tmp_flow_data_out_filename , metadata = flow_data .text )
130+
131+ # load the exported FCS file
132+ new_flow_data = FlowData (tmp_flow_data_out_filename )
133+
134+ # get both unprocessed and processed event arrays,
135+ # they should be the same as each other and as the
136+ # original processed events.
137+ new_unproc_events = new_flow_data .as_array (preprocess = False )
138+ new_proc_events = new_flow_data .as_array (preprocess = True )
139+
140+ # The only variation is floating point precision differences
141+ # from saving to a file. This should be around 7 digits, but
142+ # depending on the magnitude, the number of decimal places
143+ # vary. In this data, it's around 4 decimal places event though
144+ # the relative differences max out around 1e-7
145+ np .testing .assert_array_almost_equal (new_unproc_events , orig_proc_events , decimal = 3 )
146+ np .testing .assert_array_almost_equal (new_proc_events , orig_proc_events , decimal = 3 )
147+
118148 def test_parse_var_int_data (self ):
119149 event_values = [
120150 49135 , 61373 , 48575 , 49135 , 61373 , 48575 , 7523 , 598 , 49135 , 61373 ,
0 commit comments