Skip to content

Fix flake8-linter issues in PR #2401: resolve W293, E501, and E303 er… #2421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions docs/examples/shading/plot_partial_module_shading_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from pvlib import pvsystem, singlediode
import pandas as pd
import numpy as np
from scipy.interpolate import interp1d
from scipy.interpolate import make_interp_spline
import matplotlib.pyplot as plt

from scipy.constants import e as qe, k as kB
Expand Down Expand Up @@ -178,10 +178,16 @@ def plot_curves(dfs, labels, title):


def interpolate(df, i):
"""convenience wrapper around scipy.interpolate.interp1d"""
f_interp = interp1d(np.flipud(df['i']), np.flipud(df['v']), kind='linear',
fill_value='extrapolate')
return f_interp(i)
x = np.flipud(df['i'])
y = np.flipud(df['v'])

# Create a spline interpolation with
# linear (k=1) and extrapolation (default behavior)
spline = make_interp_spline(
x, y, k=1, bc_type='clamped'
) # Extrapolation is handled by default

return spline(i)


def combine_series(dfs):
Expand Down
11 changes: 8 additions & 3 deletions pvlib/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ def interp(aoi, theta_ref, iam_ref, method='linear', normalize=True):
'''
# Contributed by Anton Driesse (@adriesse), PV Performance Labs. July, 2019

from scipy.interpolate import interp1d
from scipy.interpolate import make_interp_spline
import numpy as np

# Scipy doesn't give the clearest feedback, so check number of points here.
MIN_REF_VALS = {'linear': 2, 'quadratic': 3, 'cubic': 4, 1: 2, 2: 3, 3: 4}
Expand All @@ -483,8 +484,12 @@ def interp(aoi, theta_ref, iam_ref, method='linear', normalize=True):
raise ValueError("Negative value(s) found in 'iam_ref'. "
"This is not physically possible.")

interpolator = interp1d(theta_ref, iam_ref, kind=method,
fill_value='extrapolate')
theta_ref = np.asarray(theta_ref)
iam_ref = np.asarray(iam_ref)

interpolator = make_interp_spline(
theta_ref, iam_ref, k=method, bc_type='clamped'
)
aoi_input = aoi

aoi = np.asanyarray(aoi)
Expand Down
12 changes: 5 additions & 7 deletions pvlib/spectrum/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import pandas as pd
import scipy.constants
from scipy.interpolate import interp1d
from scipy.interpolate import make_interp_spline


_PLANCK_BY_LIGHT_SPEED_OVER_ELEMENTAL_CHARGE_BY_BILLION = (
Expand Down Expand Up @@ -67,12 +67,10 @@ def get_example_spectral_response(wavelength=None):
resolution = 5.0
wavelength = np.arange(280, 1200 + resolution, resolution)

interpolator = interp1d(SR_DATA[0], SR_DATA[1],
kind='cubic',
bounds_error=False,
fill_value=0.0,
copy=False,
assume_sorted=True)
x_data = np.sort(SR_DATA[0])
y_data = SR_DATA[1]

interpolator = make_interp_spline(x_data, y_data, k=3, bc_type='clamped')

sr = pd.Series(data=interpolator(wavelength), index=wavelength)

Expand Down