Annotate arithmetic operations#1231
Conversation
|
Hey @jonathanberthias , thank you, great job on greatly reducing the number of errors! Here's what my Claude flagged: 1.
|
|
By the way, @jonathanberthias , apologies if I've already asked this, but what are you using SCIP for, out of curiosity? 😄 |
|
Thanks for the review, all good findings!
At my previous job, I was using it for portfolio optimization with many integer constraints as an alternative to Gurobi, and I was very impressed with the quality of the results! I don't use it that much anymore though, it's just a side-project 😄 |
Joao-Dionisio
left a comment
There was a problem hiding this comment.
Thank you once more, @jonathanberthias !
Also, very appreciative of you doing this as a side hobby :)
Regarding the company you were working at, do you know if they're still using SCIP and if we could get in contact with them? We're collecting industrial users, and could perhaps offer some help.
As a follow up to #1229, we can now quickly evaluate the effect of annotating all the arithmetic operations.
This PR adds annotations to the stubs for nearly all the simple cases. There are still some areas where the annotations are not correct, and they fall broadly in the following categories:
np.ndarraymethods: we are changing the return values of the operations compared to the base class, which in the best case works with atype: ignore[override]comment, and in the worst case makes it impossible to get the type checker to infer the correct resultMatrixExprreturns aMatrixExprin general, except if both are 1D in which case the result is anExpr. Likewise, operations with 0D-MatrixExprfail to type-check correctly. This kind of "shape-typing" is possible to do I believe, but is more complex than I reached for in this PRDecimal: I annotated things withfloatto keep them simple, but that is actually too restrictive. Semanticallytyping.SupportsFloatis correct, but that also matchesnp.ndarraywhich makes many operations fail to type-check. This is an open issue to be solvedTerm: somehow many operations with aTermobject succeed at runtime, but that seems wrong to mePart of #1072