6
6
7
7
from sdmetrics .demos import load_demo
8
8
from sdmetrics .reports .single_table import QualityReport
9
+ from tests .utils import get_error_type
9
10
10
11
11
12
class TestQualityReport :
@@ -262,7 +263,7 @@ def test_report_end_to_end_with_errors(self):
262
263
'Score' : [0.6621621621621622 , np .nan , 0.9953488372093023 , 0.9395348837209302 ],
263
264
'Error' : [
264
265
None ,
265
- " TypeError: '<' not supported between instances of 'str' and 'float'" ,
266
+ ' TypeError' ,
266
267
None ,
267
268
None ,
268
269
],
@@ -304,23 +305,25 @@ def test_report_end_to_end_with_errors(self):
304
305
'Real Correlation' : [np .nan ] * 6 ,
305
306
'Synthetic Correlation' : [np .nan ] * 6 ,
306
307
'Error' : [
307
- " ValueError: could not convert string to float: 'a'" ,
308
+ ' ValueError' ,
308
309
None ,
309
310
None ,
310
- " TypeError: '<=' not supported between instances of 'float' and 'str'" ,
311
- " TypeError: '<=' not supported between instances of 'float' and 'str'" ,
311
+ ' TypeError' ,
312
+ ' TypeError' ,
312
313
None ,
313
314
],
314
315
}
315
316
expected_details_column_shapes = pd .DataFrame (expected_details_column_shapes_dict )
316
317
expected_details_cpt = pd .DataFrame (expected_details_cpt__dict )
317
318
318
- pd .testing .assert_frame_equal (
319
- report .get_details ('Column Shapes' ), expected_details_column_shapes
320
- )
321
- pd .testing .assert_frame_equal (
322
- report .get_details ('Column Pair Trends' ), expected_details_cpt
323
- )
319
+ # Errors may change based on versions of scipy installed.
320
+ col_shape_report = report .get_details ('Column Shapes' )
321
+ col_pair_report = report .get_details ('Column Pair Trends' )
322
+ col_shape_report ['Error' ] = col_shape_report ['Error' ].apply (get_error_type )
323
+ col_pair_report ['Error' ] = col_pair_report ['Error' ].apply (get_error_type )
324
+
325
+ pd .testing .assert_frame_equal (col_shape_report , expected_details_column_shapes )
326
+ pd .testing .assert_frame_equal (col_pair_report , expected_details_cpt )
324
327
assert report .get_score () == 0.8204378797402054
325
328
326
329
def test_report_with_column_nan (self ):
@@ -446,10 +449,10 @@ def test_report_with_column_nan(self):
446
449
None ,
447
450
None ,
448
451
None ,
449
- 'ValueError: x and y must have length at least 2. ' ,
452
+ 'ValueError' ,
450
453
None ,
451
454
None ,
452
- 'ValueError: x and y must have length at least 2. ' ,
455
+ 'ValueError' ,
453
456
None ,
454
457
None ,
455
458
None ,
@@ -458,12 +461,17 @@ def test_report_with_column_nan(self):
458
461
expected_details_column_shapes = pd .DataFrame (expected_details_column_shapes_dict )
459
462
expected_details_cpt = pd .DataFrame (expected_details_cpt__dict )
460
463
461
- pd .testing .assert_frame_equal (
462
- report .get_details ('Column Shapes' ), expected_details_column_shapes
463
- )
464
- pd .testing .assert_frame_equal (
465
- report .get_details ('Column Pair Trends' ), expected_details_cpt
466
- )
464
+ col_shape_report = report .get_details ('Column Shapes' )
465
+ if 'Error' not in col_shape_report :
466
+ # Errors may not occur in certain scipy versions
467
+ expected_details_column_shapes .drop (columns = ['Error' ], inplace = True )
468
+
469
+ # Errors may change based on versions of library installed.
470
+ col_pair_report = report .get_details ('Column Pair Trends' )
471
+ col_pair_report ['Error' ] = col_pair_report ['Error' ].apply (get_error_type )
472
+
473
+ pd .testing .assert_frame_equal (col_shape_report , expected_details_column_shapes )
474
+ pd .testing .assert_frame_equal (col_pair_report , expected_details_cpt )
467
475
468
476
def test_report_with_verbose (self , capsys ):
469
477
"""Test the report with verbose.
0 commit comments