Skip to content

Error when adding MatrixExpr to GenExpr #1066

@jonathanberthias

Description

@jonathanberthias

Describe the bug

There is a bug when adding a GenExpr with a MatrixExpr. Note that the bug disappears if the GenExpr is added to the MatrixExpr.

To Reproduce

With a fresh environment where I installed PySCIPOpt 5.6.0 from PyPI:

Python 3.13.6 (main, Aug  8 2025, 17:08:22) [Clang 20.1.4 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyscipopt as scip
>>> m = scip.Model()
>>> x = m.addVar()
>>> y = m.addMatrixVar((1,))
>>> y + x**0.5
MatrixExpr([sum(0.0,prod(1.0,x2),**(sum(0.0,prod(1.0,x1)),0.5))],
           dtype=object)
>>> x**0.5 + y
Traceback (most recent call last):
  File "<python-input-5>", line 1, in <module>
    x**0.5 + y
    ~~~~~~~^~~
  File "src/pyscipopt/expr.pxi", line 439, in pyscipopt.scip.GenExpr.__add__
AttributeError: 'numpy.ndarray' object has no attribute 'getOp'

Expected behavior

The addition should work, and give the same result no matter the order of arguments.

System

  • OS: Ubuntu
  • Version 24.04
  • SCIP version 9.2.3
  • How did you install pyscipopt? 5.6.0 from PyPI

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions