-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: reintroduce invalid_value in bisect #33
Conversation
Co-authored-by: Halvor Lund <[email protected]>
linerate/solver.py
Outdated
@@ -142,4 +148,4 @@ def compute_conductor_ampacity( | |||
""" | |||
f = partial(heat_balance, max_conductor_temperature) | |||
|
|||
return bisect(f, min_ampacity, max_ampacity, tolerance) | |||
return bisect(f, min_ampacity, max_ampacity, tolerance, invalid_value=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't make sense to me to set this value to 0, what is the use case? I think it would be better to set to nan by default, and provide invalid_value as an input argument in compute_conductor_ampacity to be able to override. Does that solve the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use case, in my understanding, is calculating the conductor ampacity for a span for a large array of weather parameters with one function call. A span with a strict temperature limit will have an ampacity that is frequently 0 (i.e. can't be used in many weather conditions). From bisect's perspective, that means the heat equation never equals zero.
If this is a common usage of compute_conductor_ampacity
, I think returning 0-ampacity as a proxy for "this line can't be used under these conditions" makes sense. That way, the returned array can be used without post-processing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current proposed solution is what @gunnhildsp suggested.
Due to unforeseen complications in using
bisect
without aninvalid_value
parameter, I suggest reverting previous changes and re-introducing theinvalid_value
inbisect
and by extensioncompute_conductor_ampacity