From aaf33eb71aea2a30fe42f0e95adf3778472aeca9 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 10 Jul 2019 09:54:59 -0500 Subject: [PATCH] Add kwargs to forecast.get_data with tests (#746) * Add kwargs to forecast.get_data with tests * Update whatsnew * Fix a mis-placed merge in whatsnew/v0.7.0.rst * Simplify the tests in test_forecast.py and add descriptive comment --- docs/sphinx/source/whatsnew/v0.7.0.rst | 6 +++++- pvlib/forecast.py | 4 +++- pvlib/test/test_forecast.py | 28 ++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.7.0.rst b/docs/sphinx/source/whatsnew/v0.7.0.rst index 98a2dc6469..4cebea992f 100644 --- a/docs/sphinx/source/whatsnew/v0.7.0.rst +++ b/docs/sphinx/source/whatsnew/v0.7.0.rst @@ -8,11 +8,15 @@ recommend all users of v0.6.3 upgrade to this release after checking API compatibility notes. **Python 2.7 support ended on June 1, 2019**. (:issue:`501`) - **Minimum numpy version is now 1.10.4. Minimum pandas version is now 0.18.1.** +Bug fixes +~~~~~~~~~ +* Fix handling of keyword arguments in `forecasts.get_processed_data`. + (:issue:`745`) Contributors ~~~~~~~~~~~~ * Mark Campanellli (:ghuser:`markcampanelli`) * Will Holmgren (:ghuser:`wholmgren`) +* Oscar Dowson (:ghuser:`odow`) diff --git a/pvlib/forecast.py b/pvlib/forecast.py index bc93e96da5..52aa16041b 100644 --- a/pvlib/forecast.py +++ b/pvlib/forecast.py @@ -201,7 +201,7 @@ def set_location(self, time, latitude, longitude): def get_data(self, latitude, longitude, start, end, vert_level=None, query_variables=None, - close_netcdf_data=True): + close_netcdf_data=True, **kwargs): """ Submits a query to the UNIDATA servers using Siphon NCSS and converts the netcdf data to a pandas DataFrame. @@ -223,6 +223,8 @@ def get_data(self, latitude, longitude, start, end, close_netcdf_data: bool, default True Controls if the temporary netcdf data file should be closed. Set to False to access the raw data. + **kwargs: + Additional keyword arguments are silently ignored. Returns ------- diff --git a/pvlib/test/test_forecast.py b/pvlib/test/test_forecast.py index 2ff37c0ad6..d98deb357c 100644 --- a/pvlib/test/test_forecast.py +++ b/pvlib/test/test_forecast.py @@ -75,6 +75,34 @@ def test_process_data(model): .format(model, variable)) +@requires_siphon +def test_bad_kwarg_get_data(): + # For more information on why you would want to pass an unknown keyword + # argument, see Github issue #745. + amodel = NAM() + data = amodel.get_data(_latitude, _longitude, _start, _end, + bad_kwarg=False) + assert not data.empty + + +@requires_siphon +def test_bad_kwarg_get_processed_data(): + # For more information on why you would want to pass an unknown keyword + # argument, see Github issue #745. + amodel = NAM() + data = amodel.get_processed_data(_latitude, _longitude, _start, _end, + bad_kwarg=False) + assert not data.empty + + +@requires_siphon +def test_how_kwarg_get_processed_data(): + amodel = NAM() + data = amodel.get_processed_data(_latitude, _longitude, _start, _end, + how='clearsky_scaling') + assert not data.empty + + @requires_siphon def test_vert_level(): amodel = NAM()