88
99
1010@pytest .fixture
11- def testfile ():
12- return DATA_DIR / 'CRNS0101-05-2019-AZ_Tucson_11_W.txt'
13-
14-
15- def test_read_crn (testfile ):
16- columns = [
11+ def columns ():
12+ return [
1713 'WBANNO' , 'UTC_DATE' , 'UTC_TIME' , 'LST_DATE' , 'LST_TIME' , 'CRX_VN' ,
1814 'longitude' , 'latitude' , 'temp_air' , 'PRECIPITATION' , 'ghi' ,
1915 'ghi_flag' ,
2016 'SURFACE_TEMPERATURE' , 'ST_TYPE' , 'ST_FLAG' , 'relative_humidity' ,
2117 'relative_humidity_flag' , 'SOIL_MOISTURE_5' , 'SOIL_TEMPERATURE_5' ,
2218 'WETNESS' , 'WET_FLAG' , 'wind_speed' , 'wind_speed_flag' ]
19+
20+
21+ @pytest .fixture
22+ def dtypes ():
23+ return [
24+ dtype ('int64' ), dtype ('int64' ), dtype ('int64' ), dtype ('int64' ),
25+ dtype ('int64' ), dtype ('O' ), dtype ('float64' ), dtype ('float64' ),
26+ dtype ('float64' ), dtype ('float64' ), dtype ('float64' ),
27+ dtype ('int64' ), dtype ('float64' ), dtype ('O' ), dtype ('int64' ),
28+ dtype ('float64' ), dtype ('int64' ), dtype ('float64' ),
29+ dtype ('float64' ), dtype ('int64' ), dtype ('int64' ), dtype ('float64' ),
30+ dtype ('int64' )]
31+
32+
33+ @pytest .fixture
34+ def testfile ():
35+ return DATA_DIR / 'CRNS0101-05-2019-AZ_Tucson_11_W.txt'
36+
37+
38+ @pytest .fixture
39+ def testfile_problems ():
40+ return DATA_DIR / 'CRN_with_problems.txt'
41+
42+
43+ def test_read_crn (testfile , columns , dtypes ):
2344 index = pd .DatetimeIndex (['2019-01-01 16:10:00' ,
2445 '2019-01-01 16:15:00' ,
2546 '2019-01-01 16:20:00' ,
@@ -34,16 +55,26 @@ def test_read_crn(testfile):
3455 0.0 , 340.0 , 0 , 4.3 , 'C' , 0 , 83.0 , 0 , nan , nan , 1183 , 0 , 0.53 , 0 ],
3556 [53131 , 20190101 , 1625 , 20190101 , 925 , 3 , - 111.17 , 32.24 , 4.0 ,
3657 0.0 , 393.0 , 0 , 4.8 , 'C' , 0 , 81.0 , 0 , nan , nan , 1223 , 0 , 0.64 , 0 ]])
37- dtypes = [
38- dtype ('int64' ), dtype ('int64' ), dtype ('int64' ), dtype ('int64' ),
39- dtype ('int64' ), dtype ('int64' ), dtype ('float64' ), dtype ('float64' ),
40- dtype ('float64' ), dtype ('float64' ), dtype ('float64' ),
41- dtype ('int64' ), dtype ('float64' ), dtype ('O' ), dtype ('int64' ),
42- dtype ('float64' ), dtype ('int64' ), dtype ('float64' ),
43- dtype ('float64' ), dtype ('int64' ), dtype ('int64' ), dtype ('float64' ),
44- dtype ('int64' )]
4558 expected = pd .DataFrame (values , columns = columns , index = index )
4659 for (col , _dtype ) in zip (expected .columns , dtypes ):
4760 expected [col ] = expected [col ].astype (_dtype )
4861 out = crn .read_crn (testfile )
4962 assert_frame_equal (out , expected )
63+
64+
65+ def test_read_crn_problems (testfile_problems , columns , dtypes ):
66+ # GH1025
67+ index = pd .DatetimeIndex (['2020-07-06 12:00:00' ,
68+ '2020-07-06 13:10:00' ],
69+ freq = None ).tz_localize ('UTC' )
70+ values = np .array ([
71+ [92821 , 20200706 , 1200 , 20200706 , 700 , '3' , - 80.69 , 28.62 , 24.9 ,
72+ 0.0 , 190.0 , 0 , 25.5 , 'C' , 0 , 93.0 , 0 , nan , nan , 990 , 0 , 1.57 , 0 ],
73+ [92821 , 20200706 , 1310 , 20200706 , 810 , '2.623' , - 80.69 , 28.62 ,
74+ 26.9 , 0.0 , 430.0 , 0 , 30.2 , 'C' , 0 , 87.0 , 0 , nan , nan , 989 , 0 ,
75+ 1.64 , 0 ]])
76+ expected = pd .DataFrame (values , columns = columns , index = index )
77+ for (col , _dtype ) in zip (expected .columns , dtypes ):
78+ expected [col ] = expected [col ].astype (_dtype )
79+ out = crn .read_crn (testfile_problems )
80+ assert_frame_equal (out , expected )
0 commit comments