Skip to content

Conversation

@Zeroto521
Copy link
Contributor

@Zeroto521 Zeroto521 commented Jan 22, 2026

_is_number(Expr) always return False. Because Expr doesn't have __float__ method and it isn't a number type.

In [1]: from pyscipopt import Model, Expr

In [2]: from pyscipopt.scip import CONST

In [3]: e = Expr({CONST: -1.0})

In [4]: float(e)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 1
----> 1 float(e)

TypeError: float() argument must be a string or a real number, not 'pyscipopt.scip.Expr'

In [5]: float(e+1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[5], line 1
----> 1 float(e+1)

TypeError: float() argument must be a string or a real number, not 'pyscipopt.scip.Expr'

Copilot AI review requested due to automatic review settings January 22, 2026 06:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes dead code from the Expr class by eliminating checks for _is_number(self) which always return False since Expr instances cannot be converted to float.

Changes:

  • Removed unreachable code branches in __add__, __mul__, and __rtruediv__ methods that checked if self is a number
  • Simplified __rtruediv__ implementation by removing the always-false conditional check

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Joao-Dionisio Joao-Dionisio marked this pull request as draft January 22, 2026 10:08
@Zeroto521
Copy link
Contributor Author

This pr is ready.
CI fails due to performance jitter. Especially, the traceline mark is set to True.

=========================== short test summary info ============================
FAILED tests/test_matrix_variable.py::test_matrix_dot_performance[50] - assert False
 +  where False = isGT(2.9845094680786133, 3.222688674926758)
 +    where isGT = <pyscipopt.scip.Model object at 0x7f039845b440>.isGT
FAILED tests/test_matrix_variable.py::test_matrix_dot_performance[100] - assert False
 +  where False = isGT(25.479017972946167, 25.84245491027832)
 +    where isGT = <pyscipopt.scip.Model object at 0x7f0364f4b5c0>.isGT
= 2 failed, 408 passed, 104 skipped, 11 xfailed, 4 warnings in 157.89s (0:02:37) =
/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/coverage/control.py:958: CoverageWarning: No data was collected. (no-data-collected); see https://coverage.readthedocs.io/en/7.13.1/messages.html#warning-no-data-collected
  self._warn("No data was collected.", slug="no-data-collected")

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.

1 participant