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

feat: reintroduce invalid_value in bisect #33

Merged
merged 3 commits into from
Jun 14, 2024

Conversation

amundfr
Copy link
Collaborator

@amundfr amundfr commented Jun 11, 2024

Due to unforeseen complications in using bisect without an invalid_value parameter, I suggest reverting previous changes and re-introducing the invalid_value in bisect and by extension compute_conductor_ampacity

@amundfr amundfr self-assigned this Jun 11, 2024
linerate/solver.py Outdated Show resolved Hide resolved
@@ -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)
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

@halvorlu halvorlu merged commit e828901 into main Jun 14, 2024
8 checks passed
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

Successfully merging this pull request may close these issues.

3 participants