Skip to content

Commit 6dc8d48

Browse files
committed
Handle flake8 issues in part of the codebase.
1 parent 770bcd1 commit 6dc8d48

File tree

9 files changed

+48
-32
lines changed

9 files changed

+48
-32
lines changed

pvlib/clearsky.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,11 @@ def _clearsky_get_threshold(sample_interval):
668668
window_length = np.interp(sample_interval, data_freq, [50, 60, 90, 120])
669669
mean_diff = np.interp(sample_interval, data_freq, [75, 75, 75, 75])
670670
max_diff = np.interp(sample_interval, data_freq, [60, 65, 75, 90])
671-
lower_line_length = np.interp(sample_interval, data_freq, [-45,-45,-45,-45])
671+
lower_line_length = np.interp(sample_interval, data_freq,
672+
[-45, -45, -45, -45])
672673
upper_line_length = np.interp(sample_interval, data_freq, [80, 80, 80, 80])
673-
var_diff = np.interp(sample_interval, data_freq, [0.005, 0.01, 0.032, 0.07])
674+
var_diff = np.interp(sample_interval, data_freq,
675+
[0.005, 0.01, 0.032, 0.07])
674676
slope_dev = np.interp(sample_interval, data_freq, [50, 60, 75, 96])
675677

676678
return (window_length, mean_diff, max_diff, lower_line_length,

pvlib/iotools/acis.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _get_acis(start, end, params, map_variables, url, **kwargs):
5555
metadata = payload['meta']
5656

5757
try:
58-
# for StnData endpoint, unpack combination "ll" into lat, lon
58+
# for StnData endpoint, unpack combination "ll" into lat, lon
5959
metadata['lon'], metadata['lat'] = metadata.pop('ll')
6060
except KeyError:
6161
pass
@@ -244,7 +244,6 @@ def get_acis_nrcc(latitude, longitude, start, end, grid, map_variables=True,
244244
return df, meta
245245

246246

247-
248247
def get_acis_mpe(latitude, longitude, start, end, map_variables=True,
249248
url="https://data.rcc-acis.org/GridData", **kwargs):
250249
"""
@@ -453,7 +452,7 @@ def get_acis_available_stations(latitude_range, longitude_range,
453452
-------
454453
stations : pandas.DataFrame
455454
A dataframe of station metadata, one row per station.
456-
The ``sids`` column contains IDs that can be used with
455+
The ``sids`` column contains IDs that can be used with
457456
:py:func:`get_acis_station_data`.
458457
459458
Raises
@@ -489,7 +488,7 @@ def get_acis_available_stations(latitude_range, longitude_range,
489488
params = {
490489
"bbox": bbox,
491490
"meta": ("name,state,sids,sid_dates,ll,elev,"
492-
"uid,county,climdiv,tzo,network"),
491+
"uid,county,climdiv,tzo,network"),
493492
}
494493
if start is not None and end is not None:
495494
params['elems'] = ['maxt', 'mint', 'avgt', 'obst',

pvlib/iotools/midc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@
108108

109109

110110
def _format_index(data):
111-
"""Create DatetimeIndex for the Dataframe localized to the timezone provided
111+
"""
112+
Create DatetimeIndex for the Dataframe localized to the timezone provided
112113
as the label of the second (time) column.
113114
114115
Parameters
@@ -132,7 +133,8 @@ def _format_index(data):
132133

133134

134135
def _format_index_raw(data):
135-
"""Create DatetimeIndex for the Dataframe localized to the timezone provided
136+
"""
137+
Create DatetimeIndex for the Dataframe localized to the timezone provided
136138
as the label of the third column.
137139
138140
Parameters

pvlib/irradiance.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ def _handle_extra_radiation_types(datetime_or_doy, epoch_year):
132132
# a better way to do it.
133133
if isinstance(datetime_or_doy, pd.DatetimeIndex):
134134
to_doy = tools._pandas_to_doy # won't be evaluated unless necessary
135-
def to_datetimeindex(x): return x # noqa: E306
135+
def to_datetimeindex(x): # noqa: E306
136+
return x
136137
to_output = partial(pd.Series, index=datetime_or_doy)
137138
elif isinstance(datetime_or_doy, pd.Timestamp):
138139
to_doy = tools._pandas_to_doy
@@ -146,12 +147,14 @@ def to_datetimeindex(x): return x # noqa: E306
146147
tools._datetimelike_scalar_to_datetimeindex
147148
to_output = tools._scalar_out
148149
elif np.isscalar(datetime_or_doy): # ints and floats of various types
149-
def to_doy(x): return x # noqa: E306
150+
def to_doy(x): # noqa: E306
151+
return x
150152
to_datetimeindex = partial(tools._doy_to_datetimeindex,
151153
epoch_year=epoch_year)
152154
to_output = tools._scalar_out
153155
else: # assume that we have an array-like object of doy
154-
def to_doy(x): return x # noqa: E306
156+
def to_doy(x): # noqa: E306
157+
return x
155158
to_datetimeindex = partial(tools._doy_to_datetimeindex,
156159
epoch_year=epoch_year)
157160
to_output = tools._array_out

pvlib/singlediode.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,9 @@ def _lambertw_v_from_i(current, photocurrent, saturation_current,
782782

783783
# Explicit solutions where Gsh=0
784784
if np.any(idx_z):
785-
V[idx_z] = a[idx_z] * np.log1p((IL[idx_z] - I[idx_z]) / I0[idx_z]) - \
786-
I[idx_z] * Rs[idx_z]
785+
V[idx_z] = \
786+
a[idx_z] * np.log1p((IL[idx_z] - I[idx_z]) / I0[idx_z]) - \
787+
I[idx_z] * Rs[idx_z]
787788

788789
# Only compute using LambertW if there are cases with Gsh>0
789790
if np.any(idx_p):
@@ -865,17 +866,21 @@ def _lambertw_i_from_v(voltage, photocurrent, saturation_current,
865866

866867
# Explicit solutions where Rs=0
867868
if np.any(idx_z):
868-
I[idx_z] = IL[idx_z] - I0[idx_z] * np.expm1(V[idx_z] / a[idx_z]) - \
869-
Gsh[idx_z] * V[idx_z]
869+
I[idx_z] = \
870+
IL[idx_z] - I0[idx_z] * np.expm1(V[idx_z] / a[idx_z]) - \
871+
Gsh[idx_z] * V[idx_z]
870872

871873
# Only compute using LambertW if there are cases with Rs>0
872874
# Does NOT handle possibility of overflow, github issue 298
873875
if np.any(idx_p):
874876
# LambertW argument, cannot be float128, may overflow to np.inf
875-
argW = Rs[idx_p] * I0[idx_p] / (
876-
a[idx_p] * (Rs[idx_p] * Gsh[idx_p] + 1.)) * \
877-
np.exp((Rs[idx_p] * (IL[idx_p] + I0[idx_p]) + V[idx_p]) /
878-
(a[idx_p] * (Rs[idx_p] * Gsh[idx_p] + 1.)))
877+
argW = (
878+
Rs[idx_p] * I0[idx_p]
879+
/ (a[idx_p] * (Rs[idx_p] * Gsh[idx_p] + 1.))
880+
* np.exp(
881+
(Rs[idx_p] * (IL[idx_p] + I0[idx_p]) + V[idx_p])
882+
/ (a[idx_p] * (Rs[idx_p] * Gsh[idx_p] + 1.))
883+
))
879884

880885
# lambertw typically returns complex value with zero imaginary part
881886
# may overflow to np.inf
@@ -884,9 +889,10 @@ def _lambertw_i_from_v(voltage, photocurrent, saturation_current,
884889
# Eqn. 2 in Jain and Kapoor, 2004
885890
# I = -V/(Rs + Rsh) - (a/Rs)*lambertwterm + Rsh*(IL + I0)/(Rs + Rsh)
886891
# Recast in terms of Gsh=1/Rsh for better numerical stability.
887-
I[idx_p] = (IL[idx_p] + I0[idx_p] - V[idx_p] * Gsh[idx_p]) / \
888-
(Rs[idx_p] * Gsh[idx_p] + 1.) - (
889-
a[idx_p] / Rs[idx_p]) * lambertwterm
892+
I[idx_p] = \
893+
(IL[idx_p] + I0[idx_p] - V[idx_p] * Gsh[idx_p]) / \
894+
(Rs[idx_p] * Gsh[idx_p] + 1.) - (a[idx_p] / Rs[idx_p]) * \
895+
lambertwterm
890896

891897
if output_is_scalar:
892898
return I.item()

pvlib/solarposition.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,8 @@ def equation_of_time_spencer71(dayofyear):
10531053
Myers [4]_ and printed in both the Fourier paper from the Sundial
10541054
Mailing List and R. Hulstrom's [5]_ book.
10551055
1056-
.. _Fourier paper: http://www.mail-archive.com/[email protected]/msg01050.html
1056+
.. _Fourier paper:
1057+
http://www.mail-archive.com/[email protected]/msg01050.html
10571058
10581059
Parameters
10591060
----------
@@ -1101,7 +1102,8 @@ def equation_of_time_pvcdrom(dayofyear):
11011102
`PVCDROM`_ is a website by Solar Power Lab at Arizona State
11021103
University (ASU)
11031104
1104-
.. _PVCDROM: http://www.pveducation.org/pvcdrom/2-properties-sunlight/solar-time
1105+
.. _PVCDROM:
1106+
http://www.pveducation.org/pvcdrom/2-properties-sunlight/solar-time
11051107
11061108
Parameters
11071109
----------

pvlib/spa.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,11 @@ def nocompile(*args, **kwargs):
402402
@jcompile('float64(int64, int64, int64, int64, int64, int64, int64)',
403403
nopython=True)
404404
def julian_day_dt(year, month, day, hour, minute, second, microsecond):
405-
"""This is the original way to calculate the julian day from the NREL paper.
405+
"""
406+
This is the original way to calculate the julian day from the NREL paper.
406407
However, it is much faster to convert to unix/epoch time and then convert
407-
to julian day. Note that the date must be UTC."""
408+
to julian day. Note that the date must be UTC.
409+
"""
408410
if month <= 2:
409411
year = year-1
410412
month = month+12
@@ -461,6 +463,7 @@ def sum_mult_cos_add_mult(arr, x):
461463
s += arr[row, 0] * np.cos(arr[row, 1] + arr[row, 2] * x)
462464
return s
463465

466+
464467
@jcompile('float64(float64)', nopython=True)
465468
def heliocentric_longitude(jme):
466469
l0 = sum_mult_cos_add_mult(L0, jme)
@@ -475,6 +478,7 @@ def heliocentric_longitude(jme):
475478
l = np.rad2deg(l_rad)
476479
return l % 360
477480

481+
478482
@jcompile('float64(float64)', nopython=True)
479483
def heliocentric_latitude(jme):
480484
b0 = sum_mult_cos_add_mult(B0, jme)
@@ -762,9 +766,10 @@ def topocentric_elevation_angle_without_atmosphere(observer_latitude,
762766

763767

764768
@jcompile('float64(float64, float64, float64, float64)', nopython=True)
765-
def atmospheric_refraction_correction(local_pressure, local_temp,
766-
topocentric_elevation_angle_wo_atmosphere,
767-
atmos_refract):
769+
def atmospheric_refraction_correction(
770+
local_pressure, local_temp,
771+
topocentric_elevation_angle_wo_atmosphere,
772+
atmos_refract):
768773
# switch sets delta_e when the sun is below the horizon
769774
switch = topocentric_elevation_angle_wo_atmosphere >= -1.0 * (
770775
0.26667 + atmos_refract)

pvlib/spectrum/mismatch.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import pandas as pd
1010
from scipy.integrate import trapezoid
1111

12-
from warnings import warn
13-
1412

1513
def calc_spectral_mismatch_field(sr, e_sun, e_ref=None):
1614
"""

pvlib/temperature.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import numpy as np
77
import pandas as pd
88
from pvlib.tools import sind
9-
from pvlib._deprecation import warn_deprecated
109
from pvlib.tools import _get_sample_intervals
1110
import scipy
1211
import scipy.constants

0 commit comments

Comments
 (0)