question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider replacing inverter methods in PVSystem with a single method with a kwarg

See original GitHub issue

#886 moved inverter-related functions from pvsystem.py to inverter.py. Methods PVSystem.snlinverter and PVsystem.adrinverter currently wrap inverter.sandia and inverter.adr, respectively, which previously were pvsystem.snlinverter and pvsystem.adrinverter.

Perhaps renaming the functions creates potential for confusion.

It may be an improved API to replace PVSystem.snlinverter, PVSystem.adrinverter and PVSystem.pvwatts_ac with a single method PVSystem.dc_to_ac or similar, with a kwarg model='sandia' for example.

Opening for discussion.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
cwhansecommented, Jan 22, 2021

ModelChain.get_ac wouldn’t have that issue, I think, since it can inspect ModelChain.results.dc and get what’s needed.

For PVSystem.get_ac(pdc, vdc=None) is similar to what I see done in e.g. scipy.optimize.minimize where many methods are wrapped, and some kwargs are needed for some but not all methods.

0reactions
wholmgrencommented, Jan 22, 2021

Method generally looks good to me. A few suggestions:

  • model is required, so it should be an arg or a kwarg with a non-None default value.
  • I think the _validate_per_array calls belong outside the if block.
  • replace the if model not in ['sandia', 'pvwatts'] with an else block that raises the same ValueError

I think it’s easier on the user to build the multi-array inverter model selection into this method.

I’m ok with that. Would you apply the same logic to the modelchain layer? That would be my preference.

ModelChain.get_ac presents a different problem.

We don’t necessarily need to do that at the same time. Those ModelChain methods should be cleaned up but I’m less concerned about them. I don’t think anyone uses them directly and I wouldn’t have concerns about changing them without deprecation.

As for actual implementation, one way might be to set the attribute equal to a partial(self.system.get_ac, model=ac_model).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source code for pvlib.pvsystem
The ``pvsystem`` module contains functions for modeling the output and performance of PV modules and inverters. """ from __future__ import division import ...
Read more >
PVLIB_Python Documentation - Read the Docs
pvlib python is a community supported tool that provides a set of functions and classes for simulating the performance.
Read more >
How To Use *args and **kwargs in Python 3 - DigitalOcean
In Python, the single-asterisk form of *args can be used as a ... x and y as function parameters, and instead replacing them...
Read more >
Python args and kwargs: Demystified
*args and **kwargs allow you to pass multiple arguments or keyword arguments to a function. Consider the following example. This is a simple...
Read more >
python - Inheritance best practice : *args, **kwargs or explicitly ...
At the same time I don't think it's correct for all your methods to have a signature of *args , **kwargs . Explicit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found