55import pytest
66from psm_utils import PSMList
77
8+ from im2deep ._io_helpers import parse_input , validate_psm_list
89from im2deep .exceptions import IM2DeepError
9- from im2deep .utils import (
10- ccs2im ,
11- im2ccs ,
12- parse_input ,
13- validate_psm_list ,
14- )
10+ from im2deep .utils import ccs2im , im2ccs
1511
1612
1713class TestValidatePSMList :
@@ -28,6 +24,7 @@ def test_validate_psm_list_with_ccs(self, sample_psm_list_with_ccs):
2824 result = validate_psm_list (sample_psm_list_with_ccs , needs_target = True )
2925 assert isinstance (result , PSMList )
3026 for psm in result :
27+ assert psm .metadata is not None
3128 assert "CCS" in psm .metadata
3229 # CCS should always be stored as float
3330 assert isinstance (psm .metadata ["CCS" ], float )
@@ -46,7 +43,7 @@ def test_validate_psm_list_empty(self):
4643 def test_validate_psm_list_not_psm_list (self ):
4744 """Test validation fails with non-PSMList input."""
4845 with pytest .raises (IM2DeepError , match = "PSMList" ):
49- validate_psm_list ([1 , 2 , 3 ])
46+ validate_psm_list ([1 , 2 , 3 ]) # type: ignore
5047
5148
5249class TestParseInput :
@@ -131,6 +128,7 @@ def test_parse_input_legacy_format_detection(self, tmp_path):
131128 assert len (result ) == 2
132129 # Check that CCS values are preserved in metadata
133130 for psm in result :
131+ assert psm .metadata is not None
134132 assert "CCS" in psm .metadata
135133
136134
@@ -142,7 +140,7 @@ def test_ccs2im_basic(self):
142140 ccs = 450.0
143141 charge = 2
144142 mz = 500.0
145- im = ccs2im (ccs , charge , mz )
143+ im = ccs2im (ccs , mz , charge )
146144
147145 assert isinstance (im , float )
148146 assert im > 0
@@ -153,7 +151,7 @@ def test_ccs2im_array(self):
153151 charge = np .array ([2 , 3 , 2 ])
154152 mz = np .array ([500.0 , 600.0 , 550.0 ])
155153
156- im = ccs2im (ccs , charge , mz )
154+ im = ccs2im (ccs , mz , charge )
157155
158156 assert isinstance (im , np .ndarray )
159157 assert len (im ) == len (ccs )
@@ -164,7 +162,7 @@ def test_im2ccs_basic(self):
164162 im = 1.0
165163 charge = 2
166164 mz = 500.0
167- ccs = im2ccs (im , charge , mz )
165+ ccs = im2ccs (im , mz , charge )
168166
169167 assert isinstance (ccs , float )
170168 assert ccs > 0
@@ -175,7 +173,7 @@ def test_im2ccs_array(self):
175173 charge = np .array ([2 , 3 , 2 ])
176174 mz = np .array ([500.0 , 600.0 , 550.0 ])
177175
178- ccs = im2ccs (im , charge , mz )
176+ ccs = im2ccs (im , mz , charge )
179177
180178 assert isinstance (ccs , np .ndarray )
181179 assert len (ccs ) == len (im )
@@ -187,34 +185,34 @@ def test_ccs2im_im2ccs_roundtrip(self):
187185 charge = 2
188186 mz = 500.0
189187
190- im = ccs2im (ccs_original , charge , mz )
191- ccs_roundtrip = im2ccs (im , charge , mz )
188+ im = ccs2im (ccs_original , mz , charge )
189+ ccs_roundtrip = im2ccs (im , mz , charge )
192190
193191 assert abs (ccs_roundtrip - ccs_original ) < 0.01
194192
195193 def test_ccs2im_zero_values (self ):
196194 """Test handling of zero values."""
197195 with pytest .raises ((ValueError , ZeroDivisionError )):
198- ccs2im (0 , 2 , 500 )
196+ ccs2im (0 , 500 , 2 )
199197
200198 def test_im2ccs_zero_values (self ):
201199 """Test handling of zero values."""
202200 with pytest .raises ((ValueError , ZeroDivisionError )):
203- im2ccs (0 , 2 , 500 )
201+ im2ccs (0 , 500 , 2 )
204202
205203 def test_ccs2im_negative_values (self ):
206204 """Test handling of negative values."""
207205 # Function should raise ValueError for negative CCS values
208206 with pytest .raises (ValueError , match = "CCS must be positive" ):
209- ccs2im (- 450.0 , 2 , 500 )
207+ ccs2im (- 450.0 , 500 , 2 )
210208
211209 def test_im2ccs_different_charges (self ):
212210 """Test conversions with different charge states."""
213211 im = 1.0
214212 mz = 500
215213
216- ccs_z2 = im2ccs (im , 2 , mz )
217- ccs_z3 = im2ccs (im , 3 , mz )
214+ ccs_z2 = im2ccs (im , mz , 2 )
215+ ccs_z3 = im2ccs (im , mz , 3 )
218216
219217 assert ccs_z2 != ccs_z3
220218 assert ccs_z2 > 0 and ccs_z3 > 0
0 commit comments