Hullo Sympy Group,
I have a series of relations that I am receiving from an outside object and code base. These equations are in no particular format, and I want to convert them to one. At the moment, the end format I need is
format: lhs_expression [op] constant
example: 3x + 4y <= 7
I have code that currently looks like this:
-----
lhs, rhs = rel.lhs, rel.rhs
lhs -= rhs
rhs = 0
possible_constant = lhs.as_ordered_terms()[ -1 ]
if possible_constant.is_real:
lhs -= possible_constant
rhs -= possible_constant
new_relation = type(rel)(lhs, rhs)
-----
Given that Sympy has already parsed the lhs expression, is there a more efficient/cleaner method of getting its constant? Something perhaps like:
-----
lhs, rhs = rel.lhs, rel.rhs
lhs -= rhs
rhs = -lhs.constant_term
lhs -= rhs
new_relation = type(rel)(lhs, rhs)
-----
Thanks,
Kevin