44import pytest
55
66from isic_challenge_scoring import load_csv
7- from isic_challenge_scoring .types import ScoreException
7+ from isic_challenge_scoring .types import ScoreError
88
99
1010def test_parse_truth_csv (categories ):
@@ -97,7 +97,7 @@ def test_parse_csv_no_newlines(categories):
9797 prediction_file_stream .write (f'{ i :030f} ,' )
9898 prediction_file_stream .seek (0 )
9999
100- with pytest .raises (ScoreException , match = r'^No newlines detected in CSV\.$' ):
100+ with pytest .raises (ScoreError , match = r'^No newlines detected in CSV\.$' ):
101101 load_csv .parse_csv (prediction_file_stream , categories )
102102
103103
@@ -106,7 +106,7 @@ def test_parse_csv_empty(categories):
106106 prediction_file_stream = io .StringIO ('\n \n ' )
107107
108108 with pytest .raises (
109- ScoreException , match = r'^Could not parse CSV: "No columns to parse from file"\.$'
109+ ScoreError , match = r'^Could not parse CSV: "No columns to parse from file"\.$'
110110 ):
111111 load_csv .parse_csv (prediction_file_stream , categories )
112112
@@ -115,7 +115,7 @@ def test_parse_csv_invalid_unicode(categories):
115115 prediction_file_stream = io .TextIOWrapper (io .BytesIO (b'\xef ' ))
116116
117117 with pytest .raises (
118- ScoreException , match = r'^Could not parse CSV: could not decode file as UTF-8\.$'
118+ ScoreError , match = r'^Could not parse CSV: could not decode file as UTF-8\.$'
119119 ):
120120 load_csv .parse_csv (prediction_file_stream , categories )
121121
@@ -129,7 +129,7 @@ def test_parse_csv_mismatched_headers(categories):
129129 )
130130
131131 # Pandas should drop extra columns without headers, but this is a common invalid case
132- with pytest .raises (ScoreException , match = r'^Missing columns in CSV:' ):
132+ with pytest .raises (ScoreError , match = r'^Missing columns in CSV:' ):
133133 load_csv .parse_csv (prediction_file_stream , categories )
134134
135135
@@ -138,7 +138,7 @@ def test_parse_csv_missing_columns(categories):
138138 'image,MEL,BCC,AKIEC,BKL,DF\n ' 'ISIC_0000123,1.0,0.0,0.0,0.0,0.0\n '
139139 )
140140
141- with pytest .raises (ScoreException , match = r"^Missing columns in CSV: \['NV', 'VASC'\]\.$" ):
141+ with pytest .raises (ScoreError , match = r"^Missing columns in CSV: \['NV', 'VASC'\]\.$" ):
142142 load_csv .parse_csv (prediction_file_stream , categories )
143143
144144
@@ -148,7 +148,7 @@ def test_parse_csv_extra_columns(categories):
148148 'ISIC_0000123,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0\n '
149149 )
150150
151- with pytest .raises (ScoreException , match = r"^Extra columns in CSV: \['BAZ', 'FOO'\]\.$" ):
151+ with pytest .raises (ScoreError , match = r"^Extra columns in CSV: \['BAZ', 'FOO'\]\.$" ):
152152 load_csv .parse_csv (prediction_file_stream , categories )
153153
154154
@@ -157,7 +157,7 @@ def test_parse_csv_misnamed_columns(categories):
157157 'image,MEL,FOO,BCC,AKIEC,BKL,BAZ,VASC\n ' 'ISIC_0000123,1.0,0.0,0.0,0.0,0.0,0.0,0.0\n '
158158 )
159159
160- with pytest .raises (ScoreException , match = r"^Missing columns in CSV: \['DF', 'NV'\]\.$" ):
160+ with pytest .raises (ScoreError , match = r"^Missing columns in CSV: \['DF', 'NV'\]\.$" ):
161161 load_csv .parse_csv (prediction_file_stream , categories )
162162
163163
@@ -200,7 +200,7 @@ def test_parse_csv_missing_index(categories):
200200 'MEL,NV,BCC,AKIEC,BKL,DF,VASC\n ' '1.0,0.0,0.0,0.0,0.0,0.0,0.0\n '
201201 )
202202
203- with pytest .raises (ScoreException , match = r"^Missing column in CSV: 'image'\.$" ):
203+ with pytest .raises (ScoreError , match = r"^Missing column in CSV: 'image'\.$" ):
204204 load_csv .parse_csv (prediction_file_stream , categories )
205205
206206
@@ -224,7 +224,7 @@ def test_parse_csv_missing_values(categories):
224224 )
225225
226226 with pytest .raises (
227- ScoreException ,
227+ ScoreError ,
228228 match = r"^Missing value\(s\) in CSV for images: \['ISIC_0000124', 'ISIC_0000125'\]\.$" ,
229229 ):
230230 load_csv .parse_csv (prediction_file_stream , categories )
@@ -239,7 +239,7 @@ def test_parse_csv_non_float_columns(categories):
239239 )
240240
241241 with pytest .raises (
242- ScoreException ,
242+ ScoreError ,
243243 match = r"^CSV contains non-floating-point value\(s\) in columns: \['BCC', 'VASC'\]\.$" ,
244244 ):
245245 load_csv .parse_csv (prediction_file_stream , categories )
@@ -254,7 +254,7 @@ def test_parse_csv_out_of_range_values(categories):
254254 )
255255
256256 with pytest .raises (
257- ScoreException ,
257+ ScoreError ,
258258 match = r'^Values in CSV are outside the interval \[0\.0, 1\.0\] for images: '
259259 r"\['ISIC_0000123', 'ISIC_0000125'\]\.$" ,
260260 ):
@@ -271,7 +271,7 @@ def test_parse_csv_duplicate_images(categories):
271271 )
272272
273273 with pytest .raises (
274- ScoreException ,
274+ ScoreError ,
275275 match = r"^Duplicate image rows detected in CSV: \['ISIC_0000123', 'ISIC_0000124'\]\.$" ,
276276 ):
277277 load_csv .parse_csv (prediction_file_stream , categories )
@@ -298,7 +298,7 @@ def test_validate_rows_missing_images(categories):
298298 prediction_probabilities = pd .DataFrame (
299299 [[1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ]], index = ['ISIC_0000123' ], columns = categories
300300 )
301- with pytest .raises (ScoreException , match = r"^Missing images in CSV: \['ISIC_0000124'\]\.$" ):
301+ with pytest .raises (ScoreError , match = r"^Missing images in CSV: \['ISIC_0000124'\]\.$" ):
302302 load_csv .validate_rows (truth_probabilities , prediction_probabilities )
303303
304304 truth_probabilities = pd .DataFrame (
@@ -310,7 +310,7 @@ def test_validate_rows_missing_images(categories):
310310 [[1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ]], index = ['ISIC_0000120' ], columns = categories
311311 )
312312 with pytest .raises (
313- ScoreException , match = r"^Missing images in CSV: \['ISIC_0000123', 'ISIC_0000124'\]\.$"
313+ ScoreError , match = r"^Missing images in CSV: \['ISIC_0000123', 'ISIC_0000124'\]\.$"
314314 ):
315315 load_csv .validate_rows (truth_probabilities , prediction_probabilities )
316316
@@ -324,7 +324,7 @@ def test_validate_rows_missing_images(categories):
324324 index = ['ISIC_0000123' , 'ISIC_0000125' ],
325325 columns = categories ,
326326 )
327- with pytest .raises (ScoreException , match = r"^Missing images in CSV: \['ISIC_0000124'\]\.$" ):
327+ with pytest .raises (ScoreError , match = r"^Missing images in CSV: \['ISIC_0000124'\]\.$" ):
328328 load_csv .validate_rows (truth_probabilities , prediction_probabilities )
329329
330330
@@ -342,7 +342,7 @@ def test_validate_rows_extra_images(categories):
342342 columns = categories ,
343343 )
344344 with pytest .raises (
345- ScoreException , match = r"^Extra images in CSV: \['ISIC_0000126', 'ISIC_0000127'\]\.$"
345+ ScoreError , match = r"^Extra images in CSV: \['ISIC_0000126', 'ISIC_0000127'\]\.$"
346346 ):
347347 load_csv .validate_rows (truth_probabilities , prediction_probabilities )
348348
0 commit comments