Skip to content

Commit

Permalink
Fix code style issues flagged by LGTM (#1559)
Browse files Browse the repository at this point in the history
* fixing issues

* fix long lines

* whats new file edited

* Comments from review

Co-authored-by: Christian Orner <[email protected]>
  • Loading branch information
chrisorner and Christian Orner authored Sep 27, 2022
1 parent 73965c2 commit bdbaf4c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
4 changes: 3 additions & 1 deletion docs/sphinx/source/whatsnew/v0.9.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ Deprecations

Enhancements
~~~~~~~~~~~~

* Multiple code style issues fixed that were reported by LGTM analysis. (:issue:`1275`, :pull:`1559`)

Bug fixes
~~~~~~~~~



Testing
~~~~~~~

Expand All @@ -33,3 +34,4 @@ Requirements

Contributors
~~~~~~~~~~~~
* Christian Orner (:ghuser:`chrisorner`)
1 change: 0 additions & 1 deletion pvlib/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from pvlib.location import Location
from pvlib.irradiance import campbell_norman, get_extra_radiation, disc
from pvlib.irradiance import _liujordan
from siphon.catalog import TDSCatalog
from siphon.ncss import NCSS

Expand Down
10 changes: 6 additions & 4 deletions pvlib/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def martin_ruiz_diffuse(surface_tilt, a_r=0.16, c1=0.4244, c2=None):
# avoid undefined results for horizontal or upside-down surfaces
zeroang = 1e-06


surface_tilt = np.where(surface_tilt == 0, zeroang, surface_tilt)
surface_tilt = np.where(surface_tilt == 180, 180 - zeroang, surface_tilt)

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

beta = np.radians(surface_tilt)

from numpy import pi, sin, cos, exp
sin = np.sin
pi = np.pi
cos = np.cos

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

iam_sky = 1 - exp(-(c1 + c2 * trig_term_sky) * trig_term_sky / a_r)
iam_gnd = 1 - exp(-(c1 + c2 * trig_term_gnd) * trig_term_gnd / a_r)
iam_sky = 1 - np.exp(-(c1 + c2 * trig_term_sky) * trig_term_sky / a_r)
iam_gnd = 1 - np.exp(-(c1 + c2 * trig_term_gnd) * trig_term_gnd / a_r)

if out_index is not None:
iam_sky = pd.Series(iam_sky, index=out_index, name='iam_sky')
Expand Down
13 changes: 7 additions & 6 deletions pvlib/iotools/epw.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,15 @@ def read_epw(filename, coerce_year=None):
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 '
'Safari/537.36')})
response = urlopen(request)
csvdata = io.StringIO(response.read().decode(errors='ignore'))
with io.StringIO(response.read().decode(errors='ignore')) as csvdata:
data, meta = parse_epw(csvdata, coerce_year)

else:
# Assume it's accessible via the file system
csvdata = open(str(filename), 'r')
try:
data, meta = parse_epw(csvdata, coerce_year)
finally:
csvdata.close()
with open(str(filename), 'r') as csvdata:
data, meta = parse_epw(csvdata, coerce_year)


return data, meta


Expand Down
1 change: 0 additions & 1 deletion pvlib/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import datetime
import warnings

import pandas as pd
import pytz
Expand Down
1 change: 0 additions & 1 deletion pvlib/temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,6 @@ def fuentes(poa_global, temp_air, wind_speed, noct_installed, module_height=5,

# iterate through timeseries inputs
sun0 = 0
tmod0 = 293.15

# n.b. the way Fuentes calculates the first timedelta makes it seem like
# the value doesn't matter -- rather than recreate it here, just assume
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python

import os
import sys

try:
from setuptools import setup, find_namespace_packages
Expand Down

0 comments on commit bdbaf4c

Please sign in to comment.