99
1010from unittest import mock
1111import pytest
12- import pandas .util . testing as pdtest
12+ import pandas .testing as pdtest
1313from wqio .tests import helpers
1414
1515from wqio .features import Location , Dataset
@@ -33,7 +33,7 @@ def check_stat(expected_csv, result, comp=False):
3333 pdtest .assert_frame_equal (
3434 expected .sort_index (axis = "columns" ),
3535 result .sort_index (axis = "columns" ).round (6 ),
36- check_less_precise = True ,
36+ atol = 1e-5 ,
3737 )
3838
3939
@@ -308,7 +308,7 @@ def test_geostd_dev(dc):
308308def test_shapiro (dc ):
309309 known_csv = """\
310310 station,Inflow,Inflow,Outflow,Outflow,Reference,Reference
311- result,pvalue,shapiro ,pvalue,shapiro ,pvalue,shapiro
311+ result,pvalue,statistic ,pvalue,statistic ,pvalue,statistic
312312 param,,,,,,
313313 A,1.8e-05,0.685783,1e-06,0.576069,4e-06,0.61735
314314 B,1e-06,0.594411,0.0,0.530962,0.0,0.41471
@@ -324,7 +324,7 @@ def test_shapiro(dc):
324324def test_shapiro_log (dc ):
325325 known_csv = """\
326326 station,Inflow,Inflow,Outflow,Outflow,Reference,Reference
327- result,log-shapiro ,pvalue,log-shapiro ,pvalue,log-shapiro ,pvalue
327+ result,statistic ,pvalue,statistic ,pvalue,statistic ,pvalue
328328 param,,,,,,
329329 A,0.983521938,0.96662426,0.979861856,0.913820148,0.939460814,0.234214202
330330 B,0.957531095,0.390856266,0.97048676,0.722278714,0.967978418,0.735424638
@@ -467,27 +467,27 @@ def test_levene(dc):
467467@helpers .seed
468468def test_wilcoxon (dc ):
469469 known_csv = """\
470- ,,pvalue,pvalue,pvalue, wilcoxon,wilcoxon,wilcoxon
470+ ,,wilcoxon,wilcoxon,wilcoxon,pvalue,pvalue,pvalue
471471 loc_2,,Inflow,Outflow,Reference,Inflow,Outflow,Reference
472472 param,loc_1,,,,,,
473- A,Inflow,,0.0351569731,0.4074344561,,32 .0,59.0
474- A,Outflow,0.0351569731,,0.2552905052,32.0,,46.0
475- A,Reference,0.4074344561,0.2552905052,,59 .0,46.0 ,
476- B,Inflow,,0.6001794871,0.1823383542,,38 .0,22.0
477- B,Outflow,0.6001794871,,0.8588630128,38.0,,31.0
478- B,Reference,0.1823383542,0.8588630128,,22 .0,31.0 ,
479- C,Inflow,,0.1592244176,0.5840564537,,75 .0,120.0
480- C,Outflow,0.1592244176,,0.4470311612,75.0,,113.0
481- C,Reference,0.5840564537,0.4470311612,,120 .0,113.0 ,
482- D,Inflow,,0.5936182408,0.5302845968,,44 .0,31.0
483- D,Outflow,0.5936182408,,0.9721253297,44.0,,45.0
484- D,Reference,0.5302845968,0.9721253297,,31 .0,45.0 ,
485- E,Inflow,,0.8589549227,0.3862707204,,21 .0,19.0
486- E,Outflow,0.8589549227,,0.0711892343,21.0,,16.0
487- E,Reference,0.3862707204,0.0711892343,,19 .0,16.0 ,
488- F,Inflow,,0.4924592975,0.952765022,,62 .0,22.0
489- F,Outflow,0.4924592975,,0.6566419343,62.0,,28.0
490- F,Reference,0.952765022,0.6566419343,,22 .0,28.0
473+ A,Inflow,,32.0,59 .0,,0.03479,0.430679
474+ A,Outflow,32.0,,46.0,0.03479,,0.274445
475+ A,Reference,59.0,46 .0,,0.430679,0.274445 ,
476+ B,Inflow,,38.0,22 .0,,0.600179,0.182338
477+ B,Outflow,38.0,,31.0,0.600179,,0.858863
478+ B,Reference,22.0,31 .0,,0.182338,0.858863 ,
479+ C,Inflow,,75.0,120 .0,,0.167807,0.601046
480+ C,Outflow,75.0,,113.0,0.167807,,0.463381
481+ C,Reference,120.0,113 .0,,0.601046,0.463381 ,
482+ D,Inflow,,44.0,31 .0,,0.593618,0.530285
483+ D,Outflow,44.0,,45.0,0.593618,,0.972125
484+ D,Reference,31.0,45 .0,,0.530285,0.972125 ,
485+ E,Inflow,,21.0,19 .0,,0.910156,0.386271
486+ E,Outflow,21.0,,16.0,0.910156,,0.077148
487+ E,Reference,19.0,16 .0,,0.386271,0.077148 ,
488+ F,Inflow,,62.0,22 .0,,0.492459,0.952765
489+ F,Outflow,62.0,,28.0,0.492459,,0.656642
490+ F,Reference,22.0,28 .0,,0.952765,0.656642,
491491 """
492492 with pytest .warns (UserWarning ):
493493 check_stat (known_csv , dc .wilcoxon , comp = True )
@@ -611,9 +611,7 @@ def test_inventory(dc):
611611 )
612612 )
613613 expected = pandas .read_csv (known_csv , index_col = [0 , 1 ]).astype (int )
614- pdtest .assert_frame_equal (
615- expected , dc .inventory .astype (int ), check_names = False , check_less_precise = True
616- )
614+ pdtest .assert_frame_equal (expected , dc .inventory .astype (int ), check_names = False )
617615
618616
619617def test_inventory_noNDs (dc_noNDs ):
@@ -644,10 +642,7 @@ def test_inventory_noNDs(dc_noNDs):
644642 )
645643 expected = pandas .read_csv (known_csv , index_col = [0 , 1 ]).astype (int )
646644 pdtest .assert_frame_equal (
647- expected ,
648- dc_noNDs .inventory .astype (int ),
649- check_names = False ,
650- check_less_precise = True ,
645+ expected , dc_noNDs .inventory .astype (int ), check_names = False ,
651646 )
652647
653648
@@ -696,11 +691,11 @@ def test_stat_summary(dc):
696691
697692 expected = pandas .read_csv (known_csv , index_col = [0 , 1 ]).T
698693 pdtest .assert_frame_equal (
699- expected ,
700- dc .stat_summary (),
694+ expected . round ( 5 ) ,
695+ dc .stat_summary (). round ( 5 ) ,
701696 check_names = False ,
702- check_less_precise = True ,
703697 check_dtype = False ,
698+ rtol = 1e-4 ,
704699 )
705700
706701
0 commit comments