as_numeric

(function from pyomo.core.expr.numvalue)

pyomo.core.expr.numvalue.as_numeric(obj)[source]

A function that creates a NumericConstant object that wraps Python numeric values.

This function also manages a cache of constants.

NOTE: This function is only intended for use when

data is added to a component.

Parameters:

obj – The numeric value that may be wrapped.

Raises: TypeError if the object is in native_types and not in

native_numeric_types

Returns: A NumericConstant object or the original object.