-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Matching Python types for return values of pvsystem.calcparams_*
#1700
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
Changes from 16 commits
f36d832
8d184fe
2842a77
95553fb
c188743
993243e
44a2a6a
fabb4eb
3cb6845
96b558b
aeaf065
0547ed7
dd2f64b
ac91f3b
8612500
43945f3
d86bc10
5d4f6d4
05a7de6
6bfc361
5e4c16c
0ff0f45
370ae3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| from pvlib import (atmosphere, iam, inverter, irradiance, | ||
| singlediode as _singlediode, temperature) | ||
| from pvlib.tools import _build_kwargs, _build_args | ||
| import pvlib.tools as tools | ||
|
|
||
|
|
||
| # a dict of required parameter names for each DC power model | ||
|
|
@@ -1913,7 +1914,7 @@ def calcparams_desoto(effective_irradiance, temp_cell, | |
| saturation_current : numeric | ||
| Diode saturation curent in amperes | ||
|
|
||
| resistance_series : float | ||
| resistance_series : numeric | ||
| Series resistance in ohms | ||
|
|
||
| resistance_shunt : numeric | ||
|
|
@@ -2036,9 +2037,20 @@ def calcparams_desoto(effective_irradiance, temp_cell, | |
| # use errstate to silence divide by warning | ||
| with np.errstate(divide='ignore'): | ||
| Rsh = R_sh_ref * (irrad_ref / effective_irradiance) | ||
|
|
||
| Rs = R_s | ||
|
|
||
| return IL, I0, Rs, Rsh, nNsVth | ||
| numeric_args = (effective_irradiance, temp_cell) | ||
| out = (IL, I0, Rs, Rsh, nNsVth) | ||
|
|
||
| if all(map(np.isscalar, numeric_args)): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. np.isscalar docs suggest that we should instead test if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the goal of |
||
| return out | ||
|
|
||
| index = tools.get_pandas_index(*numeric_args) | ||
| if index is not None: | ||
| return tuple(pd.Series(a, index=index).rename(None) for a in out) | ||
|
|
||
| return np.broadcast_arrays(*out) | ||
|
||
|
|
||
|
|
||
| def calcparams_cec(effective_irradiance, temp_cell, | ||
|
|
@@ -2117,7 +2129,7 @@ def calcparams_cec(effective_irradiance, temp_cell, | |
| saturation_current : numeric | ||
| Diode saturation curent in amperes | ||
|
|
||
| resistance_series : float | ||
| resistance_series : numeric | ||
| Series resistance in ohms | ||
|
|
||
| resistance_shunt : numeric | ||
|
|
@@ -2234,7 +2246,7 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, | |
| saturation_current : numeric | ||
| Diode saturation current in amperes | ||
|
|
||
| resistance_series : float | ||
| resistance_series : numeric | ||
| Series resistance in ohms | ||
|
|
||
| resistance_shunt : numeric | ||
|
|
@@ -2293,7 +2305,17 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, | |
|
|
||
| Rs = R_s | ||
|
|
||
| return IL, I0, Rs, Rsh, nNsVth | ||
| numeric_args = (effective_irradiance, temp_cell) | ||
| out = (IL, I0, Rs, Rsh, nNsVth) | ||
|
|
||
| if all(map(np.isscalar, numeric_args)): | ||
| return out | ||
|
|
||
| index = tools.get_pandas_index(*numeric_args) | ||
| if index is not None: | ||
| return tuple(pd.Series(a, index=index).rename(None) for a in out) | ||
|
|
||
| return np.broadcast_arrays(*out) | ||
|
|
||
|
|
||
| def retrieve_sam(name=None, path=None): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| from pvlib import tools | ||
| import numpy as np | ||
| import pandas as pd | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('keys, input_dict, expected', [ | ||
|
|
@@ -95,3 +96,16 @@ def test_degrees_to_index_1(): | |
| 'latitude' or 'longitude' is passed.""" | ||
| with pytest.raises(IndexError): # invalid value for coordinate argument | ||
| tools._degrees_to_index(degrees=22.0, coordinate='width') | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('args, item_idx', [ | ||
| ((pd.DataFrame([1], index=[1]),), 0), | ||
| ((pd.Series([1], index=[1]),), 0), | ||
| ((1, pd.Series([1], index=[1]),), 1), | ||
| ((1, pd.Series([1], index=[1]), pd.DataFrame([2], index=[2]),), 1), | ||
| ((1, pd.DataFrame([1], index=[1]), pd.Series([2], index=[2]),), 1), | ||
| ]) | ||
| def test_get_pandas_index(args, item_idx): | ||
| pd.testing.assert_index_equal( | ||
| args[item_idx].index, tools.get_pandas_index(*args) | ||
| ) | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.