Conversation
…r unary expressions Remove Python math module and use libc.math for C-level functions (fabs, exp, log, sqrt, sin, cos). Refactor unary expression evaluation by introducing specific subclasses (AbsExpr, ExpExpr, LogExpr, SqrtExpr, SinExpr, CosExpr) with dedicated evaluate methods using C functions, replacing the generic UnaryExpr implementation.
Update UnaryExpr type stubs to include concrete expression subclasses for more precise type annotations. This change refines the return type of __abs__ and introduces new expression classes. - Change __abs__ return type from GenExpr to AbsExpr - Add AbsExpr, ExpExpr, LogExpr, SqrtExpr, SinExpr, and CosExpr classes - All new classes inherit from UnaryExpr
Return a string from VarExpr.__repr__ VarExpr.__repr__ returned the wrapped Variable object instead of its name. Since Variable defines __repr__ but no __str__, str() on it fell back to __repr__, handed the non-string object back, and str.__str__ raised TypeError: __str__ returned non-string (type pyscipopt.scip.Variable). SumExpr and ProdExpr render their children with map(str, ...), so any VarExpr reached by buildGenExprObj or GenExpr.__add__/__mul__ blew up -- e.g. str(abs(x)), str(sqrt(x) * -1), and repr(2**x) vs repr(exp(x * log(2))). PowExpr and the unary __repr__ methods relied on the same implicit str(), so the leaf node is now responsible for returning a real string. Also annotate the __repr__ return type as str. @
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1259 +/- ##
==========================================
- Coverage 57.91% 57.71% -0.20%
==========================================
Files 26 27 +1
Lines 5807 5969 +162
==========================================
+ Hits 3363 3445 +82
- Misses 2444 2524 +80 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since we have all
UnaryExprsubclasses (abs, log, exp, sin, cos), we can drop theGenExpr._opattribute and usetypeinstead.