Skip to content
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

add private helper function for redundant task of preparing newton inputs #498

Closed
mikofski opened this issue Jun 30, 2018 · 0 comments
Closed

Comments

@mikofski
Copy link
Member

problem
there is WET code in singlediode_methods where the inputs to i_from_v and v_from_i are manipulated for the newton method

solution
according to this comment here's a nice snippet:

def _prepare_newton_inputs(i_or_v, args, v0):
        size, shape = _get_size_and_shape((i_or_v,) + args)
        if size > 1:
            args = [np.asarray(arg) for arg in args]
        # newton uses initial guess for the output shape
        # copy v0 to a new array and broadcast it to the shape of max size
        if shape is not None:
            v0 = np.broadcast_to(v0, shape).copy()
        else:
            v0 = voc_est
    return args, v0

alternatives
do nothing

Additional context
see #409

mikofski added a commit to mikofski/pvlib-python that referenced this issue Jul 10, 2018
* closes pvlib#498
* adds _prepare_newton_inputs(i_or_v_tup, args, v0)
* also replace verbose comment with more descriptive one to copy v0 if
it's an array to use for initial guess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant