from __future__ import division breaks CasADi

  • bransfor

    bransfor - 2012-06-26

    I stumbled on a defect in the python interface. In code I had some definitions like n = 2/3 that I wanted to evaluate as floats, so I added 'from __future__ import division' as the first statement in the file. This introduces a problem when dividing casadi.SX objects shown by the following exception:

    'TypeError: unsupported operand type(s) for /: 'SX' and 'SX'

    Of course it's trivial to work around, but it caused me some consternation until I figured out the cause. Here is an example. Try with the first line executed or commented out.

    from __future__ import division
    import casadi
    x = casadi.SX('x')
    y = casadi.SX('y')
    x / y
  • jgillis

    jgillis - 2012-09-17

    Fixed as of revision 3024


Log in to post a comment.