Skip to content

pvlib v 0.6.0.2 TypeError: ineichen() got an unexpected keyword argument 'solar_postion' #660

Closed

Description

@itprorh66

In using the location.get_clearsky method with calling parameters (times, model='ineichen', solar_postion= solpos, dni_extra=None).

When executing the statement at line 219 which reads:
cs = clearsky.ineichen(apparent_zenith, airmass_absolute,
linke_turbidity, altitude=self.altitude,
dni_extra=dni_extra, **kwargs)
the error: TypeError: ineichen() got an unexpected keyword argument 'solar_postion' is produced.

I believe this error is the result of the fact the called function, located at clearsky.py line 18, does not include the **kwargs attribute.

In earlier versions of pvlib, the statement at line 219 of location.py was as shown below:
cs = clearsky.ineichen(apparent_zenith, airmass_absolute,
linke_turbidity, altitude=self.altitude,
dni_extra=dni_extra)

Versions:

  • pvlib.__version__: 0.6.02

Activity

  1. cwhanse commented on Feb 14, 2019

    @cwhanse
    Member

    solar_postion is misspelled here, perhaps in your code also?

  2. itprorh66 commented on Feb 15, 2019

    @itprorh66
    Author
  3. markcampanelli commented on Feb 15, 2019

    @markcampanelli
    Contributor

    @itprorh66 That’s interesting and seems to suggest that using **kwargs in a function signature can let bugs in user code slip through more easily. Is that a proper understanding here?

  4. itprorh66 commented on Feb 15, 2019

    @itprorh66
    Author
  5. mikofski commented on Feb 15, 2019

    @mikofski
    Member

    @markcampanelli afaik using *args and **kwargs isn't recommend. Although I do it all the time, both pylint and pyflakes complain when I do. As the tao of Python says, "explicit is better than implicit." Oh well, live and learn. FYI: I meant this comment as agreement, not criticism. Sorry!

  6. wholmgren commented on Feb 15, 2019

    @wholmgren
    Member

    Yes, I try to avoid *args and **kwargs because they can mask errors like this one. In this situation, I used **kwargs because I thought it was silly to explicitly name all of the ineichen and simplified_solis kwargs in Location.get_clearsky. I'll appeal to the tao of Python with "explicit is better than implicit... although practicality beats purity"!

    I suspect that PR #459 caused the user code to break, but that was released several versions ago (0.6.0).

  7. cwhanse commented on Feb 15, 2019

    @cwhanse
    Member

    @itprorh66 in this case the error only cost code performance (re-computing solar position). I don't think it had any other effect.

  8. markcampanelli commented on Feb 15, 2019

    @markcampanelli
    Contributor

    Thanks all for the discussion. I just recently had the temptation to add **kwargs to make an interface more “flexible”, but now I see that my particular use case doesn’t warrant this type of trade off.

    (I’ve been trying a Python3 function design pattern that always uses required/optional keyword arguments and always returns a single dictionary (possibly with nested dictionaries). The driving API use case is where a sub-dictionary of fit parameters from the result = fit(...) function call can be passed succinctly and accurately to the “forward” model function using something like i_at_v(V_V=V_V, **result['model_params_fit']), where the currents themselves are retrieved directly with the function call as i_at_v(V_V=V_V, **result['model_params_fit'])['I_A'].)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions