8000 pyupgrade --py36-plus, license year (#1050) · unoffices/pvlib-python@766b0ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 766b0ca

Browse files
wholmgrenmikofski
andauthored
pyupgrade --py36-plus, license year (pvlib#1050)
* pyupgrade --py36-plus * update license year * stickler * test invalid model in irradiance.get_sky_diffuse * Update pvlib/atmosphere.py Co-authored-by: Mark Mikofski <bwana.marko@yahoo.com> * Update pvlib/location.py Co-authored-by: Mark Mikofski <bwana.marko@yahoo.com> * Update pvlib/modelchain.py Co-authored-by: Mark Mikofski <bwana.marko@yahoo.com> * Update pvlib/modelchain.py Co-authored-by: Mark Mikofski <bwana.marko@yahoo.com> * Update pvlib/pvsystem.py Co-authored-by: Mark Mikofski <bwana.marko@yahoo.com> * Update pvlib/pvsystem.py Co-authored-by: Mark Mikofski <bwana.marko@yahoo.com> * Update pvlib/tests/iotools/test_pvgis.py Co-authored-by: Mark Mikofski <bwana.marko@yahoo.com> * Update pvlib/tracking.py Co-authored-by: Mark Mikofski <bwana.marko@yahoo.com> * Update pvlib/tracking.py Co-authored-by: Mark Mikofski <bwana.marko@yahoo.com> * stickler Co-authored-by: Mark Mikofski <bwana.marko@yahoo.com>
1 parent 2819ac1 commit 766b0ca

25 files changed

+120
-131
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2013-2018, Sandia National Laboratories and pvlib python Development Team
3+
Copyright (c) 2013-2020, Sandia National Laboratories and pvlib python Development Team
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without modification,

docs/examples/plot_partial_module_shading_simple.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ def find_pmp(df):
322322
plt.imshow(results_pivot, origin='lower', aspect='auto')
323323
plt.xlabel('shaded fraction')
324324
plt.ylabel('diffuse fraction')
325-
xlabels = ["{:0.02f}".format(fs) for fs in results_pivot.columns[::5]]
326-
ylabels = ["{:0.02f}".format(fd) for fd in results_pivot.index]
325+
xlabels = [f"{fs:0.02f}" for fs in results_pivot.columns[::5]]
326+
ylabels = [f"{fd:0.02f}" for fd in results_pivot.index]
327327
plt.xticks(range(0, 5*len(xlabels), 5), xlabels)
328328
plt.yticks(range(0, len(ylabels)), ylabels)
329329
plt.title('Module P_mp across shading conditions')

docs/examples/plot_passias_diffuse_shading.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
for k in [1, 1.5, 2, 2.5, 3, 4, 5, 7, 10]:
4646
gcr = 1/k
4747
psi = shading.masking_angle_passias(surface_tilt, gcr)
48-
plt.plot(surface_tilt, psi, label='k={}'.format(k))
48+
plt.plot(surface_tilt, psi, label=f'k={k}')
4949

5050
plt.xlabel('Inclination angle [degrees]')
5151
plt.ylabel('Average masking angle [degrees]')
@@ -71,7 +71,7 @@
7171
shading_loss = shading.sky_diffuse_passias(psi)
7272
transposition_ratio = irradiance.isotropic(surface_tilt, dhi=1.0)
7373
relative_diffuse = transposition_ratio * (1-shading_loss) * 100 # %
74-
plt.plot(surface_tilt, relative_diffuse, label='k={}'.format(k))
74+
plt.plot(surface_tilt, relative_diffuse, label=f'k={k}')
7575

7676
plt.xlabel('Inclination angle [degrees]')
7777
plt.ylabel('Relative diffuse irradiance [%]')

docs/examples/plot_single_axis_tracking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
backtracking_position = backtracking_angles['tracker_theta'].fillna(0)
7272
backtracking_position.plot(title='Backtracking Curve',
73-
label='GCR:{:0.01f}'.format(gcr),
73+
label=f'GCR:{gcr:0.01f}',
7474
ax=ax)
7575

7676
plt.legend()

docs/examples/plot_transposition_gain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def calculate_poa(tmy, solar_position, surface_tilt, surface_azimuth):
7676
for tilt in range(0, 50, 10):
7777
# we will hardcode azimuth=180 (south) for all fixed-tilt cases
7878
poa_irradiance = calculate_poa(tmy, solar_position, tilt, 180)
79-
column_name = "FT-{}".format(tilt)
79+
column_name = f"FT-{tilt}"
8080
# TMYs are hourly, so we can just sum up irradiance [W/m^2] to get
8181
# insolation [Wh/m^2]:
8282
df_monthly[column_name] = poa_irradiance.resample('m').sum()

docs/sphinx/source/conf.py

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# PVLIB_Python documentation build configuration file, created by
43
# sphinx-quickstart on Fri Nov 7 15:56:33 2014.
@@ -15,24 +14,12 @@
1514
import sys
1615
import os
1716

18-
# Mock modules so RTD works
19-
from unittest.mock import MagicMock
20-
2117
# for warning suppression
2218
import warnings
2319

2420
# for generating GH links with linenumbers
2521
import inspect
2622

27-
28-
class Mock(MagicMock):
29-
@classmethod
30-
def __getattr__(cls, name):
31-
return Mock()
32-
33-
MOCK_MODULES = []
34-
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
35-
3623
import pandas as pd
3724
pd.show_versions()
3825

@@ -80,8 +67,9 @@ def __getattr__(cls, name):
8067
master_doc = 'index'
8168

8269
# General information about the project.
83-
project = u'pvlib-python'
84-
copyright = u'2015, Sandia National Labs, Rob Andrews, University of Arizona, github contributors'
70+
project = 'pvlib python'
71+
copyright = \
72+
'2013-2020, Sandia National Laboratories and pvlib python Development Team'
8573

8674
# The version info for the project you're documenting, acts as replacement for
8775
# |version| and |release|, also used in various other places throughout the
@@ -224,7 +212,7 @@ def __getattr__(cls, name):
224212
#html_file_suffix = None
225213

226214
# Output file base name for HTML help builder.
227-
htmlhelp_basename = 'PVLIB_Pythondoc'
215+
htmlhelp_basename = 'pvlib_pythondoc'
228216

229217

230218
# custom CSS workarounds
@@ -251,8 +239,9 @@ def setup(app):
251239
# (source start file, target name, title,
252240
# author, documentclass [howto, manual, or own class]).
253241
latex_documents = [
254-
('index', 'PVLIB_Python.tex', u'PVLIB\\_Python Documentation',
255-
u'Sandia National Labs, Rob Andrews, University of Arizona, github contributors', 'manual'),
242+
('index', 'pvlib_python.tex', 'pvlib\\_python Documentation',
243+
'Sandia National Laboratoraties and pvlib python Development Team',
244+
'manual'),
256245
]
257246

258247
# The name of an image file (relative to this directory) to place at the top of
@@ -289,8 +278,8 @@ def setup(app):
289278
# One entry per manual page. List of tuples
290279
# (source start file, name, description, authors, manual section).
291280
man_pages = [
292-
('index', 'pvlib_python', u'PVLIB_Python Documentation',
293-
[u'Sandia National Labs, Rob Andrews, University of Arizona, github contributors'], 1)
281+
('index', 'pvlib_python', 'pvlib_python Documentation',
282+
['Sandia National Laboratoraties and pvlib python Development Team'], 1)
294283
]
295284

296285
# If true, show URL addresses after external links.
@@ -303,9 +292,10 @@ def setup(app):
303292
# (source start file, target name, title, author,
304293
# dir menu entry, description, category)
305294
texinfo_documents = [
306-
('index', 'PVLIB_Python', u'PVLIB_Python Documentation',
307-
u'Sandia National Labs, Rob Andrews, University of Arizona, github contributors', 'PVLIB_Python', 'One line description of project.',
308-
'Miscellaneous'),
295+
('index', 'pvlib python', 'pvlib python Documentation',
296+
'Sandia National Laboratoraties and pvlib python Development Team',
297+
'pvlib python', 'One line description of project.',
298+
'Miscellaneous'),
309299
]
310300

311301
# Documents to append as an appendix to all manuals.
@@ -322,7 +312,7 @@ def setup(app):
322312

323313
# Example configuration for intersphinx: refer to the Python standard library.
324314
intersphinx_mapping = {
325-
'python': ('https://docs.python.org/3.7/', None),
315+
'python': ('https://docs.python.org/3.8/', None),
326316
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
327317
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
328318
}
@@ -432,7 +422,7 @@ def make_github_url(pagename):
432422
# add line numbers if possible:
433423
start, end = get_linenos(obj)
434424
if start and end:
435-
target_url += '#L{}-L{}'.format(start, end)
425+
target_url += f'#L{start}-L{end}'
436426

437427
# Just a normal source RST page
438428
else:

pvlib/atmosphere.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def get_relative_airmass(zenith, model='kastenyoung1989'):
209209

210210
if 'kastenyoung1989' == model:
211211
am = (1.0 / (np.cos(zenith_rad) +
212-
0.50572*(((6.07995 + (90 - z)) ** - 1.6364))))
212+
0.50572*((6.07995 + (90 - z)) ** - 1.6364)))
213213
elif 'kasten1966' == model:
214214
am = 1.0 / (np.cos(zenith_rad) + 0.15*((93.885 - z) ** - 1.253))
215215
elif 'simple' == model:
@@ -434,8 +434,8 @@ def first_solar_spectral_correction(pw, airmass_absolute,
434434
pw = pw.astype('float64')
435435
if np.min(pw) < min_pw:
436436
pw = np.maximum(pw, min_pw)
437-
warn('Exceptionally low pw values replaced with {0} cm to prevent '
438-
'model divergence'.format(min_pw))
437+
warn(f'Exceptionally low pw values replaced with {min_pw} cm to '
438+
'prevent model divergence')
439439

440440
# Warn user about Pw data that is exceptionally high
441441
if np.max(pw) > max_pw:

pvlib/forecast.py

Lines changed: 18 additions & 18 deletions
57AE
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
'module, or the module may be separated into its own package.')
2222

2323

24-
class ForecastModel(object):
24+
class ForecastModel:
2525
"""
2626
An object for querying and holding forecast model information for
2727
use within the pvlib library.
@@ -143,7 +143,7 @@ def connect_to_catalog(self):
143143
self.connected = True
144144

145145
def __repr__(self):
146-
return '{}, {}'.format(self.model_name, self.set_type)
146+
return f'{self.model_name}, {self.set_type}'
147147

148148
def set_dataset(self):
149149
'''
@@ -710,9 +710,9 @@ def __init__(self, resolution='half', set_type='best'):
710710

711711
resolution = resolution.title()
712712
if resolution not in self._resolutions:
713-
raise ValueError('resolution must in {}'.format(self._resolutions))
713+
raise ValueError(f'resolution must in {self._resolutions}')
714714

715-
model = 'GFS {} Degree Forecast'.format(resolution)
715+
model = f'GFS {resolution} Degree Forecast'
716716

717717
# isobaric variables will require a vert_level to prevent
718718
# excessive data downloads
@@ -746,7 +746,7 @@ def __init__(self, resolution='half', set_type='best'):
746746
'mid_clouds',
747747
'high_clouds']
748748

749-
super(GFS, self).__init__(model_type, model, set_type,
749+
super().__init__(model_type, model, set_type,
750750
vert_level=100000)
751751

752752
def process_data(self, data, cloud_cover='total_clouds', **kwargs):
@@ -766,7 +766,7 @@ def process_data(self, data, cloud_cover='total_clouds', **kwargs):
766766
data: DataFrame
767767
Processed forecast data.
768768
"""
769-
data = super(GFS, self).process_data(data, **kwargs)
769+
data = super().process_data(data, **kwargs)
770770
data['temp_air'] = self.kelvin_to_celsius(data['temp_air'])
771771
data['wind_speed'] = self.uv_to_speed(data)
772772
irrads = self.cloud_cover_to_irradiance(data[cloud_cover], **kwargs)
@@ -835,7 +835,7 @@ def __init__(self, set_type='best'):
835835
'mid_clouds',
836836
'high_clouds']
837837

838-
super(HRRR_ESRL, self).__init__(model_type, model, set_type)
838+
super().__init__(model_type, model, set_type)
839839

840840
def process_data(self, data, cloud_cover='total_clouds', **kwargs):
841841
"""
@@ -855,7 +855,7 @@ def process_data(self, data, cloud_cover='total_clouds', **kwargs):
855855
Processed forecast data.
856856
"""
857857

858-
data = super(HRRR_ESRL, self).process_data(data, **kwargs)
858+
data = super().process_data(data, **kwargs)
859859
data['temp_air'] = self.kelvin_to_celsius(data['temp_air'])
860860
data['wind_speed'] = self.gust_to_speed(data)
861861
# data['wind_speed'] = self.uv_to_speed(data) # GH 702
@@ -917,7 +917,7 @@ def __init__(self, set_type='best'):
917917
'mid_clouds',
918918
'high_clouds']
919919

920-
super(NAM, self).__init__(model_type, model, set_type)
920+
super().__init__(model_type, model, set_type)
921921

922922
def process_data(self, data, cloud_cover='total_clouds', **kwargs):
923923
"""
@@ -937,7 +937,7 @@ def process_data(self, data, cloud_cover='total_clouds', **kwargs):
937937
Processed forecast data.
938938
"""
939939

940-
data = super(NAM, self).process_data(data, **kwargs)
940+
data = super().process_data(data, **kwargs)
941941
data['temp_air'] = self.kelvin_to_celsius(data['temp_air'])
942942
data['wind_speed'] = self.gust_to_speed(data)
943943
irrads = self.cloud_cover_to_irradiance(data[cloud_cover], **kwargs)
@@ -1000,7 +1000,7 @@ def __init__(self, set_type='best'):
10001000
'mid_clouds',
10011001
'high_clouds', ]
10021002

1003-
super(HRRR, self).__init__(model_type, model, set_type)
1003+
super().__init__(model_type, model, set_type)
10041004

10051005
def process_data(self, data, cloud_cover='total_clouds', **kwargs):
10061006
"""
@@ -1019,7 +1019,7 @@ def process_data(self, data, cloud_cover='total_clouds', **kwargs):
10191019
data: DataFrame
10201020
Processed forecast data.
10211021
"""
1022-
data = super(HRRR, self).process_data(data, **kwargs)
1022+
data = super().process_data(data, **kwargs)
10231023
wind_mapping = {
10241024
'wind_speed_u': 'u-component_of_wind_height_above_ground_0',
10251025
'wind_speed_v': 'v-component_of_wind_height_above_ground_0',
@@ -1075,7 +1075,7 @@ def __init__(self, set_type='best'):
10751075
'dni',
10761076
'dhi',
10771077
'total_clouds', ]
1078-
super(NDFD, self).__init__(model_type, model, set_type)
1078+
super().__init__(model_type, model, set_type)
10791079

10801080
def process_data(self, data, **kwargs):
10811081
"""
@@ -1094,7 +1094,7 @@ def process_data(self, data, **kwargs):
10941094
"""
10951095

10961096
cloud_cover = 'total_clouds'
1097-
data = super(NDFD, self).process_data(data, **kwargs)
1097+
data = super().process_data(data, **kwargs)
10981098
data['temp_air'] = self.kelvin_to_celsius(data['temp_air'])
10991099
irrads = self.cloud_cover_to_irradiance(data[cloud_cover], **kwargs)
11001100
data = data.join(irrads, how='outer')
@@ -1137,10 +1137,10 @@ def __init__(self, resolution='20', set_type='best'):
11371137

11381138
resolution = str(resolution)
11391139
if resolution not in self._resolutions:
1140-
raise ValueError('resolution must in {}'.format(self._resolutions))
1140+
raise ValueError(f'resolution must in {self._resolutions}')
11411141

11421142
model_type = 'Forecast Model Data'
1143-
model = 'Rapid Refresh CONUS {}km'.format(resolution)
1143+
model = f'Rapid Refresh CONUS {resolution}km'
11441144
self.variables = {
11451145
'temp_air': 'Temperature_surface',
11461146
'wind_speed_gust': 'Wind_speed_gust_surface',
@@ -1158,7 +1158,7 @@ def __init__(self, resolution='20', set_type='best'):
11581158
'low_clouds',
11591159
'mid_clouds',
11601160
'high_clouds', ]
1161-
super(RAP, self).__init__(model_type, model, set_type)
1161+
super().__init__(model_type, model, set_type)
11621162

11631163
def process_data(self, data, cloud_cover='total_clouds', **kwargs):
11641164
"""
@@ -1178,7 +1178,7 @@ def process_data(self, data, cloud_cover='total_clouds', **kwargs):
11781178
Processed forecast data.
11791179
"""
11801180

1181-
data = super(RAP, self).process_data(data, **kwargs)
1181+
data = super().process_data(data, **kwargs)
11821182
data['temp_air'] = self.kelvin_to_celsius(data['temp_air'])
11831183
data['wind_speed'] = self.gust_to_speed(data)
11841184
irrads = self.cloud_cover_to_irradiance(data[cloud_cover], **kwargs)

pvlib/iam.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
# a dict of required parameter names for each IAM model
1717
# keys are the function names for the IAM models
1818
_IAM_MODEL_PARAMS = {
19-
'ashrae': set(['b']),
20-
'physical': set(['n', 'K', 'L']),
21-
'martin_ruiz': set(['a_r']),
22-
'sapm': set(['B0', 'B1', 'B2', 'B3', 'B4', 'B5']),
23-
'interp': set([])
19+
'ashrae': {'b'},
20+
'physical': {'n', 'K', 'L'},
21+
'martin_ruiz': {'a_r'},
22+
'sapm': {'B0', 'B1', 'B2', 'B3', 'B4', 'B5'},
23+
'interp': set()
2424
}
2525

2626

@@ -79,7 +79,7 @@ def ashrae(aoi, b=0.05):
7979
pvlib.iam.interp
8080
"""
8181

82-
iam = 1 - b * ((1 / np.cos(np.radians(aoi)) - 1))
82+
iam = 1 - b * (1 / np.cos(np.radians(aoi)) - 1)
8383
aoi_gte_90 = np.full_like(aoi, False, dtype='bool')
8484
np.greater_equal(np.abs(aoi), 90, where=~np.isnan(aoi), out=aoi_gte_90)
8585
iam = np.where(aoi_gte_90, 0, iam)
@@ -675,7 +675,7 @@ def marion_integrate(function, surface_tilt, region, num=None):
675675
elif region == 'horizon':
676676
num = 1800
677677
else:
678-
raise ValueError('Invalid region: {}'.format(region))
678+
raise ValueError(f'Invalid region: {region}')
679679

680680
beta = np.radians(surface_tilt)
681681
if isinstance(beta, pd.Series):
@@ -697,7 +697,7 @@ def marion_integrate(function, surface_tilt, region, num=None):
697697
elif region == 'ground':
698698
mask = (phi_range >= np.pi/2)
699699
else:
700-
raise ValueError('Invalid region: {}'.format(region))
700+
raise ValueError(f'Invalid region: {region}')
701701
phi_range = phi_range[mask]
702702

703703
# fast Cartesian product of phi and psi

pvlib/inverter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
This module contains functions for inverter modeling and for fitting inverter
43
models to data.

0 commit comments

Comments
 (0)
0