Skip to content
2 changes: 1 addition & 1 deletion pvlib/clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def _calc_taud(w, aod700, p):
# set up nan-tolerant masks
aod700_lt_0p05 = np.full_like(aod700, False, dtype='bool')
np.less(aod700, 0.05, where=~np.isnan(aod700), out=aod700_lt_0p05)
aod700_mask = np.array([aod700_lt_0p05, ~aod700_lt_0p05], dtype=np.int)
aod700_mask = np.array([aod700_lt_0p05, ~aod700_lt_0p05], dtype=int)

# create tuples of coefficients for
# aod700 < 0.05, aod700 >= 0.05
Expand Down
2 changes: 1 addition & 1 deletion pvlib/tests/iotools/test_ecmwf_macc.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_read_ecmwf_macc(expected_test_data):
expected_times = [
1351738800, 1351749600, 1351760400, 1351771200, 1351782000, 1351792800,
1351803600, 1351814400]
assert np.allclose(data.index.astype(int) // 1000000000, expected_times)
assert np.allclose(data.index.view(np.int64) // 1000000000, expected_times)
expected_aod = np.array([
0.39531226, 0.22371339, 0.18373083, 0.15010143, 0.130809, 0.11172834,
0.09741255, 0.0921606])
Expand Down
2 changes: 1 addition & 1 deletion pvlib/tests/iotools/test_tmy.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_gh865_read_tmy3_feb_leapyear_hr24():
assert all(data.index[:-1].year == 1990)
assert data.index[-1].year == 1991
# let's do a quick sanity check, are the indices monotonically increasing?
assert all(np.diff(data.index.astype(int)) == 3600000000000)
assert all(np.diff(data.index.view(np.int64)) == 3600000000000)
# according to the TMY3 manual, each record corresponds to the previous
# hour so check that the 1st hour is 1AM and the last hour is midnite
assert data.index[0].hour == 1
Expand Down
2 changes: 1 addition & 1 deletion pvlib/tests/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ def test_run_model_with_weather_noct_sam_temp(sapm_dc_snl_ac_system, location,
weather, mocker):
weather['wind_speed'] = 5
weather['temp_air'] = 10
sapm_dc_snl_ac_system.temperature_model_parameters = {
sapm_dc_snl_ac_system.arrays[0].temperature_model_parameters = {
'noct': 45, 'module_efficiency': 0.2
}
mc = ModelChain(sapm_dc_snl_ac_system, location)
Expand Down
54 changes: 24 additions & 30 deletions pvlib/tests/test_solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,18 @@ def test_sun_rise_set_transit_ephem(expected_rise_set_ephem, golden):
expected = pd.DataFrame(index=times,
columns=['sunrise', 'sunset'],
dtype='datetime64[ns]')
expected['sunrise'] = pd.Series(index=times, data=[
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunrise'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise']])
expected['sunset'] = pd.Series(index=times, data=[
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunset']])
expected['transit'] = pd.Series(index=times, data=[
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'transit'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'transit'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'transit'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'transit']])
idx_sunrise = pd.to_datetime(['2015-01-02', '2015-01-03', '2015-01-03',
'2015-01-03']).tz_localize('MST')
expected['sunrise'] = \
expected_rise_set_ephem.loc[idx_sunrise, 'sunrise'].tolist()
idx_sunset = pd.to_datetime(['2015-01-02', '2015-01-02', '2015-01-02',
'2015-01-03']).tz_localize('MST')
expected['sunset'] = \
expected_rise_set_ephem.loc[idx_sunset, 'sunset'].tolist()
idx_transit = pd.to_datetime(['2015-01-02', '2015-01-02', '2015-01-03',
'2015-01-03']).tz_localize('MST')
expected['transit'] = \
expected_rise_set_ephem.loc[idx_transit, 'transit'].tolist()

result = solarposition.sun_rise_set_transit_ephem(times,
golden.latitude,
Expand All @@ -243,21 +240,18 @@ def test_sun_rise_set_transit_ephem(expected_rise_set_ephem, golden):
expected = pd.DataFrame(index=times,
columns=['sunrise', 'sunset'],
dtype='datetime64[ns]')
expected['sunrise'] = pd.Series(index=times, data=[
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'sunrise'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunrise'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunrise'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise']])
expected['sunset'] = pd.Series(index=times, data=[
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'sunset'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'sunset'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset']])
expected['transit'] = pd.Series(index=times, data=[
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'transit'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'transit'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'transit'],
expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'transit']])
idx_sunrise = pd.to_datetime(['2015-01-01', '2015-01-02', '2015-01-02',
'2015-01-03']).tz_localize('MST')
expected['sunrise'] = \
expected_rise_set_ephem.loc[idx_sunrise, 'sunrise'].tolist()
idx_sunset = pd.to_datetime(['2015-01-01', '2015-01-01', '2015-01-02',
'2015-01-02']).tz_localize('MST')
expected['sunset'] = \
expected_rise_set_ephem.loc[idx_sunset, 'sunset'].tolist()
idx_transit = pd.to_datetime(['2015-01-01', '2015-01-01', '2015-01-02',
'2015-01-03']).tz_localize('MST')
expected['transit'] = \
expected_rise_set_ephem.loc[idx_transit, 'transit'].tolist()

result = solarposition.sun_rise_set_transit_ephem(
times,
Expand Down
28 changes: 14 additions & 14 deletions pvlib/tests/test_spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

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

lat = 39.742476
lon = -105.1786
Expand Down Expand Up @@ -266,15 +266,15 @@ def test_transit_sunrise_sunset(self):
times = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 0),
dt.datetime(2004, 12, 4, 0)]
).tz_localize(
'UTC').astype(np.int64)*1.0/10**9
'UTC').view(np.int64)*1.0/10**9
sunrise = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 7, 8, 15),
dt.datetime(2004, 12, 4, 4, 38, 57)]
).tz_localize(
'UTC').astype(np.int64)*1.0/10**9
'UTC').view(np.int64)*1.0/10**9
sunset = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 17, 1, 4),
dt.datetime(2004, 12, 4, 19, 2, 2)]
).tz_localize(
'UTC').astype(np.int64)*1.0/10**9
'UTC').view(np.int64)*1.0/10**9
times = np.array(times)
sunrise = np.array(sunrise)
sunset = np.array(sunset)
Expand All @@ -284,13 +284,13 @@ def test_transit_sunrise_sunset(self):

times = pd.DatetimeIndex([dt.datetime(1994, 1, 2), ]
).tz_localize(
'UTC').astype(np.int64)*1.0/10**9
'UTC').view(np.int64)*1.0/10**9
sunset = pd.DatetimeIndex([dt.datetime(1994, 1, 2, 16, 59, 55), ]
).tz_localize(
'UTC').astype(np.int64)*1.0/10**9
'UTC').view(np.int64)*1.0/10**9
sunrise = pd.DatetimeIndex([dt.datetime(1994, 1, 2, 7, 8, 12), ]
).tz_localize(
'UTC').astype(np.int64)*1.0/10**9
'UTC').view(np.int64)*1.0/10**9
times = np.array(times)
sunrise = np.array(sunrise)
sunset = np.array(sunset)
Expand All @@ -305,19 +305,19 @@ def test_transit_sunrise_sunset(self):
dt.datetime(2015, 8, 2),
dt.datetime(2015, 12, 2)],
).tz_localize(
'UTC').astype(np.int64)*1.0/10**9
'UTC').view(np.int64)*1.0/10**9
sunrise = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 7, 19),
dt.datetime(2015, 4, 2, 5, 43),
dt.datetime(2015, 8, 2, 5, 1),
dt.datetime(2015, 12, 2, 7, 1)],
).tz_localize(
'MST').astype(np.int64)*1.0/10**9
'MST').view(np.int64)*1.0/10**9
sunset = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 16, 49),
dt.datetime(2015, 4, 2, 18, 24),
dt.datetime(2015, 8, 2, 19, 10),
dt.datetime(2015, 12, 2, 16, 38)],
).tz_localize(
'MST').astype(np.int64)*1.0/10**9
'MST').view(np.int64)*1.0/10**9
times = np.array(times)
sunrise = np.array(sunrise)
sunset = np.array(sunset)
Expand All @@ -331,18 +331,18 @@ def test_transit_sunrise_sunset(self):
dt.datetime(2015, 8, 2),
dt.datetime(2015, 12, 2)],
).tz_localize(
'UTC').astype(np.int64)*1.0/10**9
'UTC').view(np.int64)*1.0/10**9
sunrise = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 7, 36),
dt.datetime(2015, 4, 2, 5, 58),
dt.datetime(2015, 8, 2, 5, 13),
dt.datetime(2015, 12, 2, 7, 17)],
).tz_localize('Asia/Shanghai').astype(
).tz_localize('Asia/Shanghai').view(
np.int64)*1.0/10**9
sunset = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 17, 0),
dt.datetime(2015, 4, 2, 18, 39),
dt.datetime(2015, 8, 2, 19, 28),
dt.datetime(2015, 12, 2, 16, 50)],
).tz_localize('Asia/Shanghai').astype(
).tz_localize('Asia/Shanghai').view(
np.int64)*1.0/10**9
times = np.array(times)
sunrise = np.array(sunrise)
Expand All @@ -355,7 +355,7 @@ def test_transit_sunrise_sunset(self):
def test_earthsun_distance(self):
times = (pd.date_range('2003-10-17 12:30:30', periods=1, freq='D')
.tz_localize('MST'))
unixtimes = times.tz_convert('UTC').astype(np.int64)*1.0/10**9
unixtimes = times.tz_convert('UTC').view(np.int64)*1.0/10**9
unixtimes = np.array(unixtimes)
result = self.spa.earthsun_distance(unixtimes, 64.0, 1)
assert_almost_equal(R, result, 6)
Expand Down
21 changes: 11 additions & 10 deletions pvlib/tests/test_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,17 +462,18 @@ def test_slope_aware_backtracking():
"""
Test validation data set from https://www.nrel.gov/docs/fy20osti/76626.pdf
"""
# timestamps here are UTC instead of local standard time like in report
expected_data = np.array(
[('2019-01-01T08:00-0500', 2.404287, 122.79177, -84.440, -10.899),
('2019-01-01T09:00-0500', 11.263058, 133.288729, -72.604, -25.747),
('2019-01-01T10:00-0500', 18.733558, 145.285552, -59.861, -59.861),
('2019-01-01T11:00-0500', 24.109076, 158.939435, -45.578, -45.578),
('2019-01-01T12:00-0500', 26.810735, 173.931802, -28.764, -28.764),
('2019-01-01T13:00-0500', 26.482495, 189.371536, -8.475, -8.475),
('2019-01-01T14:00-0500', 23.170447, 204.13681, 15.120, 15.120),
('2019-01-01T15:00-0500', 17.296785, 217.446538, 39.562, 39.562),
('2019-01-01T16:00-0500', 9.461862, 229.102218, 61.587, 32.339),
('2019-01-01T17:00-0500', 0.524817, 239.330401, 79.530, 5.490)],
[('2019-01-01T13:00', 2.404287, 122.79177, -84.440, -10.899),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit surprised by this change. I'm sure it works but for style and clarity I would think including the timezone is better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use DataFrame, assert_series_equal, and assert_frame_equal instead of array and assert_allclose? I think that would be more aligned with typical use cases and would solve the timezone problem.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some context here regarding numpy datetimes and timezones: https://numpy.org/doc/stable/release/1.11.0-notes.html#datetime64-changes

('2019-01-01T14:00', 11.263058, 133.288729, -72.604, -25.747),
('2019-01-01T15:00', 18.733558, 145.285552, -59.861, -59.861),
('2019-01-01T16:00', 24.109076, 158.939435, -45.578, -45.578),
('2019-01-01T17:00', 26.810735, 173.931802, -28.764, -28.764),
('2019-01-01T18:00', 26.482495, 189.371536, -8.475, -8.475),
('2019-01-01T19:00', 23.170447, 204.13681, 15.120, 15.120),
('2019-01-01T20:00', 17.296785, 217.446538, 39.562, 39.562),
('2019-01-01T21:00', 9.461862, 229.102218, 61.587, 32.339),
('2019-01-01T22:00', 0.524817, 239.330401, 79.530, 5.490)],
dtype=[
('Time', '<M8[h]'), ('ApparentElevation', '<f8'),
('SolarAzimuth', '<f8'), ('TrueTracking', '<f8'),
Expand Down
21 changes: 20 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,23 @@ exclude = pvlib/_version.py docs dist

[tool:pytest]
junit_family=xunit2
testpaths = pvlib/tests
testpaths = pvlib/tests
filterwarnings =
# warning messages to suppress from pytest output. useful in cases
# where a dependency hasn't addressed a deprecation yet, and there's
# nothing we can do to fix it ourselves.
# syntax is: action:message:category:module:lineno
# `message` is a regex matching start of warning message
# https://docs.python.org/3/library/warnings.html#the-warnings-filter

ignore:Using or importing the ABCs:DeprecationWarning:.*patsy:

# deprecation warnings from numpy 1.20
ignore:`np.object` is a deprecated alias:DeprecationWarning:.*tables:
ignore:`np.typeDict` is a deprecated alias:DeprecationWarning:.*tables:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need these?

ignore:`np.long` is a deprecated alias:DeprecationWarning:.*numba:
ignore:`np.int` is a deprecated alias:DeprecationWarning:.*(numba|scipy):
ignore:`np.bool` is a deprecated alias:DeprecationWarning:.*numba:
# warnings from netcdf4, but reported as coming from pvlib
ignore:`np.bool` is a deprecated alias:DeprecationWarning:.*(ecmwf_macc|forecast):
ignore:tostring\(\) is deprecated:DeprecationWarning:.*ecmwf_macc: