-
Notifications
You must be signed in to change notification settings - Fork 1.1k
BUG: WIP: inconsistent broadcasting of outputs from singlediode methods in #409 only #416
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
Comments
I would prefer to fail verbosely and see an error message when the code for finding output shape etc. is presented with incompatible inputs. The code is going to fail at some point but it's a challenge for many users to walk back though the stack dump and see what they did wrong. |
✔️ addressed in f976f61 - fails verbosely if can't broadcast all inputs for |
I'm curious if |
IMO the error it raises is terse, but not opaque:
|
Oh Python, how I spend too much of my life sorting out your dynamic types! |
I don't fully understand this issue.
|
Sorry @wholmgren I think this is specific to #409 proposed methods that didn't seem to be broadcasting correctly? I've tested the existing methods in the master branch with different size inputs and they seem to broadcast okay, as long as numpy arrays are used. There does seem to be some preferential treatment for Here are some examples:
|
I did add various combinations like these to the v_from_i() and i_from_v() unit tests when I added ideal device support. It’s certainly not exhaustive though. |
@mikofski can you confirm that this issue is closed by these lines: for Bishop88 with newton; here and here for LambertW methods. Given how long this has been open and the absence of other complaints about broadcasting, I'm inclined to just close this. |
The issue was raised in some comments in #410 and #409 that the rules for broadcasting outputs are inconsistent among the single diode methods
singlediode
will only broadcast the output ifphotocurrent
is an sequence, array or seriesi_from_v
will broadcast the smallest size of eithervoltage
,photocurrent
, orresistance_shunt
v_from_i
will broadcast the smallest size of eithercurrent
,photocurrent
, orresistance_shunt
In those same comments @cwhanse proposed:
I agree with this idea, and both
i_from_v
andv_from_i
already have some boilerplate code to address this (note this snippet is lifted fromv_from_i
, with variable names suited for that function, change thearguments to other methods like singlediode or mpp):
Now knowing the
size
and/or theshape
one can letnumpy.vectorize
cast the output as proposed:On a related note: @cwhanse I realize now I misread your comment and made
i_from_v
andv_from_i
fail silently instead of gracefully, oops!. This might cause some confusion, in the short term, but maybe we can address it in this issue here?@wholmgren is there a
PVLibException
class? What exception would you expect here, maybeValueError('All arguments must be either scalar or the same size.')
?The text was updated successfully, but these errors were encountered: