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

Function as_number

numpy/f2py/symbolic.py:950–960  ·  view source on GitHub ↗

Return object as INTEGER or REAL constant.

(obj, kind=4)

Source from the content-addressed store, hash-verified

948
949
950def as_number(obj, kind=4):
951 """Return object as INTEGER or REAL constant.
952 """
953 if isinstance(obj, int):
954 return Expr(Op.INTEGER, (obj, kind))
955 if isinstance(obj, float):
956 return Expr(Op.REAL, (obj, kind))
957 if isinstance(obj, Expr):
958 if obj.op in (Op.INTEGER, Op.REAL):
959 return obj
960 raise OpError(f'cannot convert {obj} to INTEGER or REAL constant')
961
962
963def as_integer(obj, kind=4):

Callers 15

test_sanityMethod · 0.90
test_tostring_fortranMethod · 0.90
test_tostring_cMethod · 0.90
test_operationsMethod · 0.90
test_fromstringMethod · 0.90
test_traverseMethod · 0.90
test_linear_solveMethod · 0.90
test_as_numer_denomMethod · 0.90
test_polynomial_atomsMethod · 0.90
tostringMethod · 0.85
__add__Method · 0.85
__radd__Method · 0.85

Calls 2

ExprClass · 0.85
OpErrorClass · 0.85

Tested by 9

test_sanityMethod · 0.72
test_tostring_fortranMethod · 0.72
test_tostring_cMethod · 0.72
test_operationsMethod · 0.72
test_fromstringMethod · 0.72
test_traverseMethod · 0.72
test_linear_solveMethod · 0.72
test_as_numer_denomMethod · 0.72
test_polynomial_atomsMethod · 0.72