Skip to content

Commit 2f08db1

Browse files
authored
De-noise CI output (#1294)
* clean up warnings * no timezones in numpy datetimes * suppress the mess * suppress another warning from netcdf4 * fix typo * correct missed PVSystem deprecation for temperature_model_parameters * escape parens in regex * numpy -> pandas in test_tracking.py * remove unnecessary suppression for tables
1 parent 518cc35 commit 2f08db1

8 files changed

+82
-71
lines changed

pvlib/clearsky.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def _calc_taud(w, aod700, p):
558558
# set up nan-tolerant masks
559559
aod700_lt_0p05 = np.full_like(aod700, False, dtype='bool')
560560
np.less(aod700, 0.05, where=~np.isnan(aod700), out=aod700_lt_0p05)
561-
aod700_mask = np.array([aod700_lt_0p05, ~aod700_lt_0p05], dtype=np.int)
561+
aod700_mask = np.array([aod700_lt_0p05, ~aod700_lt_0p05], dtype=int)
562562

563563
# create tuples of coefficients for
564564
# aod700 < 0.05, aod700 >= 0.05

pvlib/tests/iotools/test_ecmwf_macc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_read_ecmwf_macc(expected_test_data):
5757
expected_times = [
5858
1351738800, 1351749600, 1351760400, 1351771200, 1351782000, 1351792800,
5959
1351803600, 1351814400]
60-
assert np.allclose(data.index.astype(int) // 1000000000, expected_times)
60+
assert np.allclose(data.index.view(np.int64) // 1000000000, expected_times)
6161
expected_aod = np.array([
6262
0.39531226, 0.22371339, 0.18373083, 0.15010143, 0.130809, 0.11172834,
6363
0.09741255, 0.0921606])

pvlib/tests/iotools/test_tmy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_gh865_read_tmy3_feb_leapyear_hr24():
6767
assert all(data.index[:-1].year == 1990)
6868
assert data.index[-1].year == 1991
6969
# let's do a quick sanity check, are the indices monotonically increasing?
70-
assert all(np.diff(data.index.astype(int)) == 3600000000000)
70+
assert all(np.diff(data.index.view(np.int64)) == 3600000000000)
7171
# according to the TMY3 manual, each record corresponds to the previous
7272
# hour so check that the 1st hour is 1AM and the last hour is midnite
7373
assert data.index[0].hour == 1

pvlib/tests/test_modelchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ def test_run_model_with_weather_noct_sam_temp(sapm_dc_snl_ac_system, location,
717717
weather, mocker):
718718
weather['wind_speed'] = 5
719719
weather['temp_air'] = 10
720-
sapm_dc_snl_ac_system.temperature_model_parameters = {
720+
sapm_dc_snl_ac_system.arrays[0].temperature_model_parameters = {
721721
'noct': 45, 'module_efficiency': 0.2
722722
}
723723
mc = ModelChain(sapm_dc_snl_ac_system, location)

pvlib/tests/test_solarposition.py

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -204,21 +204,18 @@ def test_sun_rise_set_transit_ephem(expected_rise_set_ephem, golden):
204204
expected = pd.DataFrame(index=times,
205205
columns=['sunrise', 'sunset'],
206206
dtype='datetime64[ns]')
207-
expected['sunrise'] = pd.Series(index=times, data=[
208-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunrise'],
209-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise'],
210-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise'],
211-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise']])
212-
expected['sunset'] = pd.Series(index=times, data=[
213-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'],
214-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'],
215-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'],
216-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunset']])
217-
expected['transit'] = pd.Series(index=times, data=[
218-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'transit'],
219-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'transit'],
220-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'transit'],
221-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'transit']])
207+
idx_sunrise = pd.to_datetime(['2015-01-02', '2015-01-03', '2015-01-03',
208+
'2015-01-03']).tz_localize('MST')
209+
expected['sunrise'] = \
210+
expected_rise_set_ephem.loc[idx_sunrise, 'sunrise'].tolist()
211+
idx_sunset = pd.to_datetime(['2015-01-02', '2015-01-02', '2015-01-02',
212+
'2015-01-03']).tz_localize('MST')
213+
expected['sunset'] = \
214+
expected_rise_set_ephem.loc[idx_sunset, 'sunset'].tolist()
215+
idx_transit = pd.to_datetime(['2015-01-02', '2015-01-02', '2015-01-03',
216+
'2015-01-03']).tz_localize('MST')
217+
expected['transit'] = \
218+
expected_rise_set_ephem.loc[idx_transit, 'transit'].tolist()
222219

223220
result = solarposition.sun_rise_set_transit_ephem(times,
224221
golden.latitude,
@@ -243,21 +240,18 @@ def test_sun_rise_set_transit_ephem(expected_rise_set_ephem, golden):
243240
expected = pd.DataFrame(index=times,
244241
columns=['sunrise', 'sunset'],
245242
dtype='datetime64[ns]')
246-
expected['sunrise'] = pd.Series(index=times, data=[
247-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'sunrise'],
248-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunrise'],
249-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunrise'],
250-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise']])
251-
expected['sunset'] = pd.Series(index=times, data=[
252-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'sunset'],
253-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'sunset'],
254-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'],
255-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset']])
256-
expected['transit'] = pd.Series(index=times, data=[
257-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'transit'],
258-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'transit'],
259-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'transit'],
260-
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'transit']])
243+
idx_sunrise = pd.to_datetime(['2015-01-01', '2015-01-02', '2015-01-02',
244+
'2015-01-03']).tz_localize('MST')
245+
expected['sunrise'] = \
246+
expected_rise_set_ephem.loc[idx_sunrise, 'sunrise'].tolist()
247+
idx_sunset = pd.to_datetime(['2015-01-01', '2015-01-01', '2015-01-02',
248+
'2015-01-02']).tz_localize('MST')
249+
expected['sunset'] = \
250+
expected_rise_set_ephem.loc[idx_sunset, 'sunset'].tolist()
251+
idx_transit = pd.to_datetime(['2015-01-01', '2015-01-01', '2015-01-02',
252+
'2015-01-03']).tz_localize('MST')
253+
expected['transit'] = \
254+
expected_rise_set_ephem.loc[idx_transit, 'transit'].tolist()
261255

262256
result = solarposition.sun_rise_set_transit_ephem(
263257
times,

pvlib/tests/test_spa.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
times = (pd.date_range('2003-10-17 12:30:30', periods=1, freq='D')
3030
.tz_localize('MST'))
31-
unixtimes = np.array(times.tz_convert('UTC').astype(np.int64)*1.0/10**9)
31+
unixtimes = np.array(times.tz_convert('UTC').view(np.int64)*1.0/10**9)
3232

3333
lat = 39.742476
3434
lon = -105.1786
@@ -266,15 +266,15 @@ def test_transit_sunrise_sunset(self):
266266
times = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 0),
267267
dt.datetime(2004, 12, 4, 0)]
268268
).tz_localize(
269-
'UTC').astype(np.int64)*1.0/10**9
269+
'UTC').view(np.int64)*1.0/10**9
270270
sunrise = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 7, 8, 15),
271271
dt.datetime(2004, 12, 4, 4, 38, 57)]
272272
).tz_localize(
273-
'UTC').astype(np.int64)*1.0/10**9
273+
'UTC').view(np.int64)*1.0/10**9
274274
sunset = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 17, 1, 4),
275275
dt.datetime(2004, 12, 4, 19, 2, 2)]
276276
).tz_localize(
277-
'UTC').astype(np.int64)*1.0/10**9
277+
'UTC').view(np.int64)*1.0/10**9
278278
times = np.array(times)
279279
sunrise = np.array(sunrise)
280280
sunset = np.array(sunset)
@@ -284,13 +284,13 @@ def test_transit_sunrise_sunset(self):
284284

285285
times = pd.DatetimeIndex([dt.datetime(1994, 1, 2), ]
286286
).tz_localize(
287-
'UTC').astype(np.int64)*1.0/10**9
287+
'UTC').view(np.int64)*1.0/10**9
288288
sunset = pd.DatetimeIndex([dt.datetime(1994, 1, 2, 16, 59, 55), ]
289289
).tz_localize(
290-
'UTC').astype(np.int64)*1.0/10**9
290+
'UTC').view(np.int64)*1.0/10**9
291291
sunrise = pd.DatetimeIndex([dt.datetime(1994, 1, 2, 7, 8, 12), ]
292292
).tz_localize(
293-
'UTC').astype(np.int64)*1.0/10**9
293+
'UTC').view(np.int64)*1.0/10**9
294294
times = np.array(times)
295295
sunrise = np.array(sunrise)
296296
sunset = np.array(sunset)
@@ -305,19 +305,19 @@ def test_transit_sunrise_sunset(self):
305305
dt.datetime(2015, 8, 2),
306306
dt.datetime(2015, 12, 2)],
307307
).tz_localize(
308-
'UTC').astype(np.int64)*1.0/10**9
308+
'UTC').view(np.int64)*1.0/10**9
309309
sunrise = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 7, 19),
310310
dt.datetime(2015, 4, 2, 5, 43),
311311
dt.datetime(2015, 8, 2, 5, 1),
312312
dt.datetime(2015, 12, 2, 7, 1)],
313313
).tz_localize(
314-
'MST').astype(np.int64)*1.0/10**9
314+
'MST').view(np.int64)*1.0/10**9
315315
sunset = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 16, 49),
316316
dt.datetime(2015, 4, 2, 18, 24),
317317
dt.datetime(2015, 8, 2, 19, 10),
318318
dt.datetime(2015, 12, 2, 16, 38)],
319319
).tz_localize(
320-
'MST').astype(np.int64)*1.0/10**9
320+
'MST').view(np.int64)*1.0/10**9
321321
times = np.array(times)
322322
sunrise = np.array(sunrise)
323323
sunset = np.array(sunset)
@@ -331,18 +331,18 @@ def test_transit_sunrise_sunset(self):
331331
dt.datetime(2015, 8, 2),
332332
dt.datetime(2015, 12, 2)],
333333
).tz_localize(
334-
'UTC').astype(np.int64)*1.0/10**9
334+
'UTC').view(np.int64)*1.0/10**9
335335
sunrise = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 7, 36),
336336
dt.datetime(2015, 4, 2, 5, 58),
337337
dt.datetime(2015, 8, 2, 5, 13),
338338
dt.datetime(2015, 12, 2, 7, 17)],
339-
).tz_localize('Asia/Shanghai').astype(
339+
).tz_localize('Asia/Shanghai').view(
340340
np.int64)*1.0/10**9
341341
sunset = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 17, 0),
342342
dt.datetime(2015, 4, 2, 18, 39),
343343
dt.datetime(2015, 8, 2, 19, 28),
344344
dt.datetime(2015, 12, 2, 16, 50)],
345-
).tz_localize('Asia/Shanghai').astype(
345+
).tz_localize('Asia/Shanghai').view(
346346
np.int64)*1.0/10**9
347347
times = np.array(times)
348348
sunrise = np.array(sunrise)
@@ -355,7 +355,7 @@ def test_transit_sunrise_sunset(self):
355355
def test_earthsun_distance(self):
356356
times = (pd.date_range('2003-10-17 12:30:30', periods=1, freq='D')
357357
.tz_localize('MST'))
358-
unixtimes = times.tz_convert('UTC').astype(np.int64)*1.0/10**9
358+
unixtimes = times.tz_convert('UTC').view(np.int64)*1.0/10**9
359359
unixtimes = np.array(unixtimes)
360360
result = self.spa.earthsun_distance(unixtimes, 64.0, 1)
361361
assert_almost_equal(R, result, 6)

pvlib/tests/test_tracking.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import pvlib
99
from pvlib import tracking
10-
from .conftest import DATA_DIR, assert_frame_equal
10+
from .conftest import DATA_DIR, assert_frame_equal, assert_series_equal
1111
from pvlib._deprecation import pvlibDeprecationWarning
1212

1313
SINGLEAXIS_COL_ORDER = ['tracker_theta', 'aoi',
@@ -462,21 +462,21 @@ def test_slope_aware_backtracking():
462462
"""
463463
Test validation data set from https://www.nrel.gov/docs/fy20osti/76626.pdf
464464
"""
465-
expected_data = np.array(
466-
[('2019-01-01T08:00-0500', 2.404287, 122.79177, -84.440, -10.899),
467-
('2019-01-01T09:00-0500', 11.263058, 133.288729, -72.604, -25.747),
468-
('2019-01-01T10:00-0500', 18.733558, 145.285552, -59.861, -59.861),
469-
('2019-01-01T11:00-0500', 24.109076, 158.939435, -45.578, -45.578),
470-
('2019-01-01T12:00-0500', 26.810735, 173.931802, -28.764, -28.764),
471-
('2019-01-01T13:00-0500', 26.482495, 189.371536, -8.475, -8.475),
472-
('2019-01-01T14:00-0500', 23.170447, 204.13681, 15.120, 15.120),
473-
('2019-01-01T15:00-0500', 17.296785, 217.446538, 39.562, 39.562),
474-
('2019-01-01T16:00-0500', 9.461862, 229.102218, 61.587, 32.339),
475-
('2019-01-01T17:00-0500', 0.524817, 239.330401, 79.530, 5.490)],
476-
dtype=[
477-
('Time', '<M8[h]'), ('ApparentElevation', '<f8'),
478-
('SolarAzimuth', '<f8'), ('TrueTracking', '<f8'),
479-
('Backtracking', '<f8')])
465+
index = pd.date_range('2019-01-01T08:00', '2019-01-01T17:00', freq='h')
466+
index = index.tz_localize('Etc/GMT+5')
467+
expected_data = pd.DataFrame(index=index, data=[
468+
( 2.404287, 122.79177, -84.440, -10.899),
469+
(11.263058, 133.288729, -72.604, -25.747),
470+
(18.733558, 145.285552, -59.861, -59.861),
471+
(24.109076, 158.939435, -45.578, -45.578),
472+
(26.810735, 173.931802, -28.764, -28.764),
473+
(26.482495, 189.371536, -8.475, -8.475),
474+
(23.170447, 204.13681, 15.120, 15.120),
475+
(17.296785, 217.446538, 39.562, 39.562),
476+
( 9.461862, 229.102218, 61.587, 32.339),
477+
( 0.524817, 239.330401, 79.530, 5.490),
478+
], columns=['ApparentElevation', 'SolarAzimuth',
479+
'TrueTracking', 'Backtracking'])
480480
expected_axis_tilt = 9.666
481481
expected_slope_angle = -2.576
482482
slope_azimuth, slope_tilt = 180.0, 10.0
@@ -492,16 +492,16 @@ def test_slope_aware_backtracking():
492492
90.0-expected_data['ApparentElevation'], expected_data['SolarAzimuth'],
493493
axis_tilt, axis_azimuth, max_angle=90.0, backtrack=True, gcr=0.5,
494494
cross_axis_tilt=cross_axis_tilt)
495-
np.testing.assert_allclose(
496-
sat['tracker_theta'], expected_data['Backtracking'],
497-
rtol=1e-3, atol=1e-3)
495+
assert_series_equal(sat['tracker_theta'],
496+
expected_data['Backtracking'].rename('tracker_theta'),
497+
check_less_precise=True)
498498
truetracking = tracking.singleaxis(
499499
90.0-expected_data['ApparentElevation'], expected_data['SolarAzimuth'],
500500
axis_tilt, axis_azimuth, max_angle=90.0, backtrack=False, gcr=0.5,
501501
cross_axis_tilt=cross_axis_tilt)
502-
np.testing.assert_allclose(
503-
truetracking['tracker_theta'], expected_data['TrueTracking'],
504-
rtol=1e-3, atol=1e-3)
502+
assert_series_equal(truetracking['tracker_theta'],
503+
expected_data['TrueTracking'].rename('tracker_theta'),
504+
check_less_precise=True)
505505

506506

507507
def test_singleaxis_aoi_gh1221():

setup.cfg

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,21 @@ exclude = pvlib/_version.py docs dist
2121

2222
[tool:pytest]
2323
junit_family=xunit2
24-
testpaths = pvlib/tests
24+
testpaths = pvlib/tests
25+
filterwarnings =
26+
# warning messages to suppress from pytest output. useful in cases
27+
# where a dependency hasn't addressed a deprecation yet, and there's
28+
# nothing we can do to fix it ourselves.
29+
# syntax is: action:message:category:module:lineno
30+
# `message` is a regex matching start of warning message
31+
# https://docs.python.org/3/library/warnings.html#the-warnings-filter
32+
33+
ignore:Using or importing the ABCs:DeprecationWarning:.*patsy:
34+
35+
# deprecation warnings from numpy 1.20
36+
ignore:`np.long` is a deprecated alias:DeprecationWarning:.*numba:
37+
ignore:`np.int` is a deprecated alias:DeprecationWarning:.*(numba|scipy):
38+
ignore:`np.bool` is a deprecated alias:DeprecationWarning:.*numba:
39+
# warnings from netcdf4, but reported as coming from pvlib
40+
ignore:`np.bool` is a deprecated alias:DeprecationWarning:.*(ecmwf_macc|forecast):
41+
ignore:tostring\(\) is deprecated:DeprecationWarning:.*ecmwf_macc:

0 commit comments

Comments
 (0)