Skip to content

Commit 7d716ee

Browse files
committed
Raise if no parameters provided to retrieve_sam() (#770)
Instead of showing up a dialog.
1 parent 0a14b27 commit 7d716ee

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pvlib/pvsystem.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,11 +1781,7 @@ def retrieve_sam(name=None, path=None):
17811781
else:
17821782
csvdata = path
17831783
elif name is None and path is None:
1784-
import tkinter
1785-
from tkinter.filedialog import askopenfilename
1786-
1787-
tkinter.Tk().withdraw()
1788-
csvdata = askopenfilename()
1784+
raise ValueError("A name or path must be provided!")
17891785

17901786
return _parse_raw_sam_df(csvdata)
17911787

pvlib/test/test_pvsystem.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,15 @@ def pvsyst_module_params():
274274
return module_parameters
275275

276276

277+
def test_retrieve_sam_raise_no_parameters():
278+
"""
279+
Raise an exception if no parameters are provided to `retrieve_sam()`.
280+
"""
281+
with pytest.raises(ValueError) as error:
282+
pvsystem.retrieve_sam()
283+
assert 'A name or path must be provided!' == str(error.value)
284+
285+
277286
def test_sapm(sapm_module_params):
278287

279288
times = pd.date_range(start='2015-01-01', periods=5, freq='12H')

0 commit comments

Comments
 (0)