diff --git a/docs/sphinx/source/whatsnew/v0.9.4.rst b/docs/sphinx/source/whatsnew/v0.9.4.rst index ea89248743..c95502bae1 100644 --- a/docs/sphinx/source/whatsnew/v0.9.4.rst +++ b/docs/sphinx/source/whatsnew/v0.9.4.rst @@ -9,12 +9,13 @@ Deprecations Enhancements ~~~~~~~~~~~~ - +* Multiple code style issues fixed that were reported by LGTM analysis. (:issue:`1275`, :pull:`1559`) Bug fixes ~~~~~~~~~ + Testing ~~~~~~~ @@ -33,3 +34,4 @@ Requirements Contributors ~~~~~~~~~~~~ +* Christian Orner (:ghuser:`chrisorner`) \ No newline at end of file diff --git a/pvlib/forecast.py b/pvlib/forecast.py index ce80e0ad74..b077024b28 100644 --- a/pvlib/forecast.py +++ b/pvlib/forecast.py @@ -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 diff --git a/pvlib/iam.py b/pvlib/iam.py index dfb2729906..a8592f4036 100644 --- a/pvlib/iam.py +++ b/pvlib/iam.py @@ -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) @@ -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'): @@ -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') diff --git a/pvlib/iotools/epw.py b/pvlib/iotools/epw.py index df93e125c5..249dd76056 100644 --- a/pvlib/iotools/epw.py +++ b/pvlib/iotools/epw.py @@ -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 diff --git a/pvlib/location.py b/pvlib/location.py index 0fb3b42a04..6e8e89ee00 100644 --- a/pvlib/location.py +++ b/pvlib/location.py @@ -6,7 +6,6 @@ import os import datetime -import warnings import pandas as pd import pytz diff --git a/pvlib/temperature.py b/pvlib/temperature.py index c55155606e..e52032f6ec 100644 --- a/pvlib/temperature.py +++ b/pvlib/temperature.py @@ -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 diff --git a/setup.py b/setup.py index 2abd339723..134ec1d88c 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,6 @@ #!/usr/bin/env python import os -import sys try: from setuptools import setup, find_namespace_packages