Return expression as TERMS expression.
(obj)
| 1056 | |
| 1057 | |
| 1058 | def as_terms(obj): |
| 1059 | """Return expression as TERMS expression. |
| 1060 | """ |
| 1061 | if isinstance(obj, Expr): |
| 1062 | obj = normalize(obj) |
| 1063 | if obj.op is Op.TERMS: |
| 1064 | return obj |
| 1065 | if obj.op is Op.INTEGER: |
| 1066 | return Expr(Op.TERMS, {as_integer(1, obj.data[1]): obj.data[0]}) |
| 1067 | if obj.op is Op.REAL: |
| 1068 | return Expr(Op.TERMS, {as_real(1, obj.data[1]): obj.data[0]}) |
| 1069 | return Expr(Op.TERMS, {obj: 1}) |
| 1070 | raise OpError(f'cannot convert {type(obj)} to terms Expr') |
| 1071 | |
| 1072 | |
| 1073 | def as_factors(obj): |
searching dependent graphs…