Skip to content

Commit d2c9bcd

Browse files
authored
fix tests with python 3.6 and pandas 0.23 (#465)
* reorder test columns * update whatsnew * fix newly broken order on pre 3.6...
1 parent bd13a1b commit d2c9bcd

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

docs/sphinx/source/whatsnew/v0.6.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Enhancements
1515
Bug fixes
1616
~~~~~~~~~
1717
* Unset executable bits of irradiance.py and test_irradiance.py (:issue:`460`)
18+
* Fix failing tests due to column order on Python 3.6+ and Pandas 0.23+
19+
(:issue:`464`)
1820

1921

2022
Documentation

pvlib/test/test_modelchain.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,13 @@ def test_run_model_tracker(system, location):
173173
index=times)
174174
assert_series_equal(ac, expected, check_less_precise=2)
175175

176-
expected = pd.DataFrame(np.
176+
expect = pd.DataFrame(np.
177177
array([[ 54.82513187, 90. , 11.0039221 , 11.0039221 ],
178178
[ nan, 0. , 0. , nan]]),
179179
columns=['aoi', 'surface_azimuth', 'surface_tilt', 'tracker_theta'],
180180
index=times)
181-
assert_frame_equal(mc.tracking, expected, check_less_precise=2)
181+
expect = expect[['tracker_theta', 'aoi', 'surface_azimuth', 'surface_tilt']]
182+
assert_frame_equal(mc.tracking, expect, check_less_precise=2)
182183

183184

184185
def poadc(mc):

pvlib/test/test_tracking.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from pvlib.location import Location
1212
from pvlib import tracking
1313

14+
SINGLEAXIS_COL_ORDER = ['tracker_theta', 'aoi',
15+
'surface_azimuth', 'surface_tilt']
1416

1517
def test_solar_noon():
1618
apparent_zenith = pd.Series([10])
@@ -20,9 +22,10 @@ def test_solar_noon():
2022
max_angle=90, backtrack=True,
2123
gcr=2.0/7.0)
2224

23-
expect = pd.DataFrame({'aoi': 10, 'surface_azimuth': 90,
24-
'surface_tilt': 0, 'tracker_theta': 0},
25+
expect = pd.DataFrame({'tracker_theta': 0, 'aoi': 10,
26+
'surface_azimuth': 90, 'surface_tilt': 0},
2527
index=[0], dtype=np.float64)
28+
expect = expect[SINGLEAXIS_COL_ORDER]
2629

2730
assert_frame_equal(expect, tracker_data)
2831

@@ -36,9 +39,10 @@ def test_azimuth_north_south():
3639
max_angle=90, backtrack=True,
3740
gcr=2.0/7.0)
3841

39-
expect = pd.DataFrame({'aoi': 0, 'surface_azimuth': 90,
40-
'surface_tilt': 60, 'tracker_theta': -60},
42+
expect = pd.DataFrame({'tracker_theta': -60, 'aoi': 0,
43+
'surface_azimuth': 90, 'surface_tilt': 60},
4144
index=[0], dtype=np.float64)
45+
expect = expect[SINGLEAXIS_COL_ORDER]
4246

4347
assert_frame_equal(expect, tracker_data)
4448

@@ -63,6 +67,7 @@ def test_max_angle():
6367
expect = pd.DataFrame({'aoi': 15, 'surface_azimuth': 90,
6468
'surface_tilt': 45, 'tracker_theta': 45},
6569
index=[0], dtype=np.float64)
70+
expect = expect[SINGLEAXIS_COL_ORDER]
6671

6772
assert_frame_equal(expect, tracker_data)
6873

@@ -79,6 +84,7 @@ def test_backtrack():
7984
expect = pd.DataFrame({'aoi': 0, 'surface_azimuth': 90,
8085
'surface_tilt': 80, 'tracker_theta': 80},
8186
index=[0], dtype=np.float64)
87+
expect = expect[SINGLEAXIS_COL_ORDER]
8288

8389
assert_frame_equal(expect, tracker_data)
8490

@@ -90,6 +96,7 @@ def test_backtrack():
9096
expect = pd.DataFrame({'aoi': 52.5716, 'surface_azimuth': 90,
9197
'surface_tilt': 27.42833, 'tracker_theta': 27.4283},
9298
index=[0], dtype=np.float64)
99+
expect = expect[SINGLEAXIS_COL_ORDER]
93100

94101
assert_frame_equal(expect, tracker_data)
95102

@@ -104,8 +111,10 @@ def test_axis_tilt():
104111
gcr=2.0/7.0)
105112

106113
expect = pd.DataFrame({'aoi': 7.286245, 'surface_azimuth': 142.65730,
107-
'surface_tilt': 35.98741, 'tracker_theta': -20.88121},
114+
'surface_tilt': 35.98741,
115+
'tracker_theta': -20.88121},
108116
index=[0], dtype=np.float64)
117+
expect = expect[SINGLEAXIS_COL_ORDER]
109118

110119
assert_frame_equal(expect, tracker_data)
111120

@@ -117,6 +126,7 @@ def test_axis_tilt():
117126
expect = pd.DataFrame({'aoi': 47.6632, 'surface_azimuth': 50.96969,
118127
'surface_tilt': 42.5152, 'tracker_theta': 31.6655},
119128
index=[0], dtype=np.float64)
129+
expect = expect[SINGLEAXIS_COL_ORDER]
120130

121131
assert_frame_equal(expect, tracker_data)
122132

@@ -133,6 +143,7 @@ def test_axis_azimuth():
133143
expect = pd.DataFrame({'aoi': 30, 'surface_azimuth': 180,
134144
'surface_tilt': 0, 'tracker_theta': 0},
135145
index=[0], dtype=np.float64)
146+
expect = expect[SINGLEAXIS_COL_ORDER]
136147

137148
assert_frame_equal(expect, tracker_data)
138149

@@ -147,6 +158,7 @@ def test_axis_azimuth():
147158
expect = pd.DataFrame({'aoi': 0, 'surface_azimuth': 180,
148159
'surface_tilt': 30, 'tracker_theta': 30},
149160
index=[0], dtype=np.float64)
161+
expect = expect[SINGLEAXIS_COL_ORDER]
150162

151163
assert_frame_equal(expect, tracker_data)
152164

@@ -184,8 +196,10 @@ def test_SingleAxisTracker_tracking():
184196
tracker_data = system.singleaxis(apparent_zenith, apparent_azimuth)
185197

186198
expect = pd.DataFrame({'aoi': 7.286245, 'surface_azimuth': 142.65730 ,
187-
'surface_tilt': 35.98741, 'tracker_theta': -20.88121},
199+
'surface_tilt': 35.98741,
200+
'tracker_theta': -20.88121},
188201
index=[0], dtype=np.float64)
202+
expect = expect[SINGLEAXIS_COL_ORDER]
189203

190204
assert_frame_equal(expect, tracker_data)
191205

@@ -202,9 +216,11 @@ def test_SingleAxisTracker_tracking():
202216
apparent_azimuth = pd.Series([180+pvsyst_solar_azimuth])
203217
apparent_zenith = pd.Series([90-pvsyst_solar_height])
204218
tracker_data = pvsyst_system.singleaxis(apparent_zenith, apparent_azimuth)
205-
expect = pd.DataFrame({'aoi': 41.07852 , 'surface_azimuth': 180-18.432 ,
206-
'surface_tilt': 24.92122 , 'tracker_theta': -15.18391},
219+
expect = pd.DataFrame({'aoi': 41.07852 , 'surface_azimuth': 180-18.432,
220+
'surface_tilt': 24.92122 ,
221+
'tracker_theta': -15.18391},
207222
index=[0], dtype=np.float64)
223+
expect = expect[SINGLEAXIS_COL_ORDER]
208224

209225
assert_frame_equal(expect, tracker_data)
210226

pvlib/tracking.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,8 @@ def singleaxis(apparent_zenith, apparent_azimuth,
545545
'surface_azimuth': surface_azimuth,
546546
'surface_tilt': surface_tilt},
547547
index=times)
548-
548+
df_out = df_out[['tracker_theta', 'aoi',
549+
'surface_azimuth', 'surface_tilt']]
549550
df_out[apparent_zenith > 90] = np.nan
550551

551552
return df_out

0 commit comments

Comments
 (0)