MCPcopy Create free account
hub / github.com/numpy/numpy / as_real

Function as_real

numpy/f2py/symbolic.py:974–986  ·  view source on GitHub ↗

Return object as REAL constant.

(obj, kind=4)

Source from the content-addressed store, hash-verified

972
973
974def as_real(obj, kind=4):
975 """Return object as REAL constant.
976 """
977 if isinstance(obj, int):
978 return Expr(Op.REAL, (float(obj), kind))
979 if isinstance(obj, float):
980 return Expr(Op.REAL, (obj, kind))
981 if isinstance(obj, Expr):
982 if obj.op is Op.REAL:
983 return obj
984 elif obj.op is Op.INTEGER:
985 return Expr(Op.REAL, (float(obj.data[0]), kind))
986 raise OpError(f'cannot convert {obj} to REAL constant')
987
988
989def as_string(obj, kind=1):

Callers 5

__add__Method · 0.85
__mul__Method · 0.85
as_termsFunction · 0.85
as_term_coeffFunction · 0.85
processMethod · 0.85

Calls 2

ExprClass · 0.85
OpErrorClass · 0.85

Tested by

no test coverage detected