MCPcopy Index your code
hub / github.com/numpy/numpy / as_term_coeff

Function as_term_coeff

numpy/f2py/symbolic.py:1094–1112  ·  view source on GitHub ↗

Return expression as term-coefficient pair.

(obj)

Source from the content-addressed store, hash-verified

1092
1093
1094def as_term_coeff(obj):
1095 """Return expression as term-coefficient pair.
1096 """
1097 if isinstance(obj, Expr):
1098 obj = normalize(obj)
1099 if obj.op is Op.INTEGER:
1100 return as_integer(1, obj.data[1]), obj.data[0]
1101 if obj.op is Op.REAL:
1102 return as_real(1, obj.data[1]), obj.data[0]
1103 if obj.op is Op.TERMS:
1104 if len(obj.data) == 1:
1105 (term, coeff), = obj.data.items()
1106 return term, coeff
1107 # TODO: find common divisor of coefficients
1108 if obj.op is Op.APPLY and obj.data[0] is ArithOp.DIV:
1109 t, c = as_term_coeff(obj.data[1][0])
1110 return as_apply(ArithOp.DIV, t, obj.data[1][1]), c
1111 return obj, 1
1112 raise OpError(f'cannot convert {type(obj)} to term and coeff')
1113
1114
1115def as_numer_denom(obj):

Callers 1

normalizeFunction · 0.85

Calls 6

normalizeFunction · 0.85
as_integerFunction · 0.85
as_realFunction · 0.85
as_applyFunction · 0.85
OpErrorClass · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…