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
MAINT: optimize.linprog: ensure integrality can be an array #16684
Conversation
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.
LGTM, thanks Matt.
@@ -581,7 +581,7 @@ def linprog(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, | |||
warning_message = "x0 is used only when method is 'revised simplex'. " | |||
warn(warning_message, OptimizeWarning) | |||
|
|||
if integrality and not meth == "highs": |
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.
This isn't equivalent, right?
>>> a = [0, 0]
>>> if a:
... print("here")
...
here
>>> if np.any(a):
... print("here 2")
...
>>>
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.
No, but it's appropriate in context. It's just a little less noisy. Previously, it would warn if the user passed [0, 0], but explicitly stating that there are no inequality constraints like this doesn't affect the problem, so there's no real need to warn.
Reference issue
Closes gh-16681
What does this implement/fix?
scipy.optimize.lingprog
's newintegrality
parameter did not acceptnp.ndarray
because a branching statement relied on its "truthiness" (i.e.if integrality
). This PR fixes that and adds to an existing test to guard against regression.