Skip to content

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

Closed
@mikofski

Description

@mikofski

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

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