DEP: remove _is_number(Expr) from expr.pyi file#1168
DEP: remove _is_number(Expr) from expr.pyi file#1168Joao-Dionisio merged 7 commits intoscipopt:masterfrom
_is_number(Expr) from expr.pyi file#1168Conversation
float(Expr) can't return True
There was a problem hiding this comment.
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 ifselfis 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.
|
This pr is ready. |
|
|
|
Same failures. Can you please try with and without your changes locally and report back, please? |
Replaces manual timing with the timeit module for more accurate performance measurement in matrix operation tests. Updates assertions to require the optimized implementation to be at least 25% faster, and reduces test parameterization to n=100 for consistency.
5d66cba to
1d0e6f5
Compare
Replaces random matrix generation with a stacked matrix of zeros and ones in test_matrix_dot_performance to provide more controlled test data.
|
GitHub and local test as below for 532dee4 from time import time
import numpy as np
from pyscipopt import Model
n = 50
model = Model()
x = model.addMatrixVar((n, n))
a = np.random.rand(n, n)
conda env# packages in environment at D:\Users\Zero\AppData\Local\miniforge3\envs\cy310:
#
# Name Version Build Channel
bzip2 1.0.8 h0ad9c76_8 conda-forge
ca-certificates 2025.11.12 h4c7d964_0 conda-forge
certifi 2025.11.12 pypi_0 pypi
charset-normalizer 3.4.4 pypi_0 pypi
colorama 0.4.6 pyhd8ed1ab_1 conda-forge
cython 3.2.3 py310h23e71ea_0 conda-forge
exceptiongroup 1.3.1 pyhd8ed1ab_0 conda-forge
execnet 2.1.2 pyhd8ed1ab_0 conda-forge
idna 3.11 pypi_0 pypi
iniconfig 2.3.0 pyhd8ed1ab_0 conda-forge
libblas 3.9.0 35_h5709861_mkl conda-forge
libcblas 3.9.0 35_h2a3cdd5_mkl conda-forge
libexpat 2.7.3 hac47afa_0 conda-forge
libffi 3.5.2 h52bdfb6_0 conda-forge
libhwloc 2.11.2 default_hc8275d1_1000 conda-forge
libiconv 1.18 hc1393d2_2 conda-forge
liblapack 3.9.0 35_hf9ab0e9_mkl conda-forge
liblzma 5.8.1 h2466b09_2 conda-forge
libpython 0.2 pypi_0 pypi
libpython-static 3.10.19 hac47afa_2_cpython conda-forge
libsqlite 3.51.1 hf5d6505_1 conda-forge
libxml2 2.13.9 h741aa76_0 conda-forge
libzlib 1.3.1 h2466b09_2 conda-forge
llvm-openmp 21.1.8 h4fa8253_0 conda-forge
m2w64-binutils 2.25.1 5 conda-forge
m2w64-bzip2 1.0.6 6 conda-forge
m2w64-crt-git 5.0.0.4636.2595836 2 conda-forge
m2w64-gcc 5.3.0 6 conda-forge
m2w64-gcc-ada 5.3.0 6 conda-forge
m2w64-gcc-fortran 5.3.0 6 conda-forge
m2w64-gcc-libgfortran 5.3.0 6 conda-forge
m2w64-gcc-libs 5.3.0 7 conda-forge
m2w64-gcc-libs-core 5.3.0 7 conda-forge
m2w64-gcc-objc 5.3.0 6 conda-forge
m2w64-gmp 6.1.0 2 conda-forge
m2w64-headers-git 5.0.0.4636.c0ad18a 2 conda-forge
m2w64-isl 0.16.1 2 conda-forge
m2w64-libiconv 1.14 6 conda-forge
m2w64-libmangle-git 5.0.0.4509.2e5a9a2 2 conda-forge
m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge
m2w64-make 4.1.2351.a80a8b8 2 conda-forge
m2w64-mpc 1.0.3 3 conda-forge
m2w64-mpfr 3.1.4 4 conda-forge
m2w64-pkg-config 0.29.1 2 conda-forge
m2w64-toolchain 5.3.0 7 conda-forge
m2w64-tools-git 5.0.0.4592.90b8472 2 conda-forge
m2w64-windows-default-manifest 6.4 3 conda-forge
m2w64-winpthreads-git 5.0.0.4634.697f757 2 conda-forge
m2w64-zlib 1.2.8 10 conda-forge
mkl 2024.2.2 h57928b3_16 conda-forge
msys2-conda-epoch 20160418 1 conda-forge
numpy 2.2.6 py310h4987827_0 conda-forge
openssl 3.6.0 h725018a_0 conda-forge
packaging 25.0 pyh29332c3_1 conda-forge
pip 25.3 pyh8b19718_0 conda-forge
pluggy 1.6.0 pyhf9edf01_1 conda-forge
pthreads-win32 2.9.1 h2466b09_4 conda-forge
pygments 2.19.2 pyhd8ed1ab_0 conda-forge
pytest 9.0.2 pyhcf101f3_0 conda-forge
pytest-xdist 3.8.0 pyhd8ed1ab_0 conda-forge
python 3.10.19 hc20f281_2_cpython conda-forge
python_abi 3.10 8_cp310 conda-forge
requests 2.32.5 pypi_0 pypi
setuptools 80.9.0 pyhff2d567_0 conda-forge
tbb 2021.13.0 h62715c5_1 conda-forge
tk 8.6.13 h2c6b04d_3 conda-forge
tomli 2.3.0 pyhcf101f3_0 conda-forge
typing_extensions 4.15.0 pyhcf101f3_0 conda-forge
tzdata 2025c h8577fbf_0 conda-forge
ucrt 10.0.26100.0 h57928b3_0 conda-forge
urllib3 2.6.2 pypi_0 pypi
vc 14.3 h2b53caa_33 conda-forge
vc14_runtime 14.44.35208 h818238b_33 conda-forge
vcomp14 14.44.35208 h818238b_33 conda-forge
wheel 0.45.1 pyhd8ed1ab_1 conda-forge |
|
This is once again failing: https://github.com/scipopt/PySCIPOpt/actions/runs/21707369612/job/62601818671 @Zeroto521 , the test needs to be changed so that it passes consistently. Either that, or we revert this change. The gain, if it exists, seems very minimal. |
@Joao-Dionisio I perfer to drop all performance test cases in CI. These test cases can't show the performance gain in CI environment, but they will cause CI failing. |
_is_number(Expr)always return False. BecauseExprdoesn't have__float__method and it isn't a number type.