Skip to content

Commit bdbaf4c

Browse files
chrisornerChristian Orner
and
Christian Orner
authored
Fix code style issues flagged by LGTM (#1559)
* fixing issues * fix long lines * whats new file edited * Comments from review Co-authored-by: Christian Orner <[email protected]>
1 parent 73965c2 commit bdbaf4c

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ Deprecations
99

1010
Enhancements
1111
~~~~~~~~~~~~
12-
12+
* Multiple code style issues fixed that were reported by LGTM analysis. (:issue:`1275`, :pull:`1559`)
1313

1414
Bug fixes
1515
~~~~~~~~~
1616

1717

18+
1819
Testing
1920
~~~~~~~
2021

@@ -33,3 +34,4 @@ Requirements
3334

3435
Contributors
3536
~~~~~~~~~~~~
37+
* Christian Orner (:ghuser:`chrisorner`)

pvlib/forecast.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from pvlib.location import Location
1212
from pvlib.irradiance import campbell_norman, get_extra_radiation, disc
13-
from pvlib.irradiance import _liujordan
1413
from siphon.catalog import TDSCatalog
1514
from siphon.ncss import NCSS
1615

pvlib/iam.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ def martin_ruiz_diffuse(surface_tilt, a_r=0.16, c1=0.4244, c2=None):
353353
# avoid undefined results for horizontal or upside-down surfaces
354354
zeroang = 1e-06
355355

356+
356357
surface_tilt = np.where(surface_tilt == 0, zeroang, surface_tilt)
357358
surface_tilt = np.where(surface_tilt == 180, 180 - zeroang, surface_tilt)
358359

@@ -361,8 +362,9 @@ def martin_ruiz_diffuse(surface_tilt, a_r=0.16, c1=0.4244, c2=None):
361362
c2 = 0.5 * a_r - 0.154
362363

363364
beta = np.radians(surface_tilt)
364-
365-
from numpy import pi, sin, cos, exp
365+
sin = np.sin
366+
pi = np.pi
367+
cos = np.cos
366368

367369
# avoid RuntimeWarnings for <, sin, and cos with nan
368370
with np.errstate(invalid='ignore'):
@@ -372,8 +374,8 @@ def martin_ruiz_diffuse(surface_tilt, a_r=0.16, c1=0.4244, c2=None):
372374
trig_term_sky = sin_beta + (pi - beta - sin_beta) / (1 + cos(beta))
373375
trig_term_gnd = sin_beta + (beta - sin_beta) / (1 - cos(beta)) # noqa: E222 E261 E501
374376

375-
iam_sky = 1 - exp(-(c1 + c2 * trig_term_sky) * trig_term_sky / a_r)
376-
iam_gnd = 1 - exp(-(c1 + c2 * trig_term_gnd) * trig_term_gnd / a_r)
377+
iam_sky = 1 - np.exp(-(c1 + c2 * trig_term_sky) * trig_term_sky / a_r)
378+
iam_gnd = 1 - np.exp(-(c1 + c2 * trig_term_gnd) * trig_term_gnd / a_r)
377379

378380
if out_index is not None:
379381
iam_sky = pd.Series(iam_sky, index=out_index, name='iam_sky')

pvlib/iotools/epw.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,15 @@ def read_epw(filename, coerce_year=None):
225225
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 '
226226
'Safari/537.36')})
227227
response = urlopen(request)
228-
csvdata = io.StringIO(response.read().decode(errors='ignore'))
228+
with io.StringIO(response.read().decode(errors='ignore')) as csvdata:
229+
data, meta = parse_epw(csvdata, coerce_year)
230+
229231
else:
230232
# Assume it's accessible via the file system
231-
csvdata = open(str(filename), 'r')
232-
try:
233-
data, meta = parse_epw(csvdata, coerce_year)
234-
finally:
235-
csvdata.close()
233+
with open(str(filename), 'r') as csvdata:
234+
data, meta = parse_epw(csvdata, coerce_year)
235+
236+
236237
return data, meta
237238

238239

pvlib/location.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import os
88
import datetime
9-
import warnings
109

1110
import pandas as pd
1211
import pytz

pvlib/temperature.py

-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ def fuentes(poa_global, temp_air, wind_speed, noct_installed, module_height=5,
655655

656656
# iterate through timeseries inputs
657657
sun0 = 0
658-
tmod0 = 293.15
659658

660659
# n.b. the way Fuentes calculates the first timedelta makes it seem like
661660
# the value doesn't matter -- rather than recreate it here, just assume

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22

33
import os
4-
import sys
54

65
try:
76
from setuptools import setup, find_namespace_packages

0 commit comments

Comments
 (0)