Skip to content

DEP: remove getOp and Operator - #1259

Open
Zeroto521 wants to merge 17 commits into
scipopt:masterfrom
Zeroto521:RemoveOP
Open

Zeroto521 wants to merge 17 commits into
scipopt:masterfrom
Zeroto521:RemoveOP

Conversation

@Zeroto521

Copy link
Copy Markdown
Contributor

Since we have all UnaryExpr subclasses (abs, log, exp, sin, cos), we can drop the GenExpr._op attribute and use type instead.

Zeroto521 added 12 commits June 8, 2026 21:50
…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
Copilot AI lite review requested due to automatic review settings September 19, 2026 02:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@
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

codecov Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.21429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 57.71%. Comparing base (9547994) to head (c8ed7ef).
⚠️ Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
src/pyscipopt/scip.pxi 93.33% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants