def register_arithmetic_ufunc(register_inferer, register_unbound, binary_ufunc): register_inferer(np, binary_ufunc, binary_map) register_unbound(np, binary_ufunc, "reduce", reduce_) register_unbound(np, binary_ufunc, "accumulate", accumulate) register_unbound(np, binary_ufunc, "reduceat", reduceat) register_unbound(np, binary_ufunc, "outer", outer)
"Parse the result type for np.empty_like calls" if a is None: return None if a.is_array: if dtype: dtype_type = get_dtype(dtype) if dtype_type is None: return a dtype = dtype_type.dtype else: dtype = a.dtype return typesystem.array(dtype, a.ndim) register_inferer(np, 'empty_like', empty_like) register_inferer(np, 'zeros_like', empty_like) register_inferer(np, 'ones_like', empty_like) def empty(shape, dtype, order): if shape is None: return None dtype = get_dtype(dtype, float64) if shape.is_int: ndim = 1 elif shape.is_tuple or shape.is_list: ndim = shape.size else: return None
'bitwise_or', 'bitwise_xor', 'left_shift', 'right_shift', ) binary_ufuncs_arithmetic = ( # Arithmetic ufuncs 'add', 'subtract', 'multiply', 'true_divide', 'floor_divide', 'divide', ) #------------------------------------------------------------------------ # Register our type functions #------------------------------------------------------------------------ register_inferer(np, 'sum', reduce_) register_inferer(np, 'prod', reduce_) for binary_ufunc in binary_ufuncs_bitwise + binary_ufuncs_arithmetic: register_inferer(np, binary_ufunc, binary_map) register_unbound(np, binary_ufunc, "reduce", reduce_) for binary_ufunc in binary_ufuncs_compare + binary_ufuncs_logical: register_inferer(np, binary_ufunc, binary_map_bool) register_unbound(np, binary_ufunc, "reduce", reduce_bool)
def register_bool_ufunc(register_inferer, register_unbound, binary_ufunc): register_inferer(np, binary_ufunc, binary_map_bool) register_unbound(np, binary_ufunc, "reduce", reduce_bool) register_unbound(np, binary_ufunc, "accumulate", accumulate_bool) register_unbound(np, binary_ufunc, "reduceat", reduceat_bool) register_unbound(np, binary_ufunc, "outer", outer_bool)
"Parse the result type for np.empty_like calls" if a is None: return None if a.is_array: if dtype: dtype_type = get_dtype(dtype) if dtype_type is None: return a dtype = dtype_type.dtype else: dtype = a.dtype return typesystem.array(dtype, a.ndim) register_inferer(np, 'empty_like', empty_like) register_inferer(np, 'zeros_like', empty_like) register_inferer(np, 'ones_like', empty_like) def empty(shape, dtype, order): if shape is None: return None dtype = get_dtype(dtype, float64) if dtype is None: return object_ if shape.is_int: ndim = 1 elif shape.is_tuple or shape.is_list: ndim = shape.size
# Arithmetic ufuncs 'add', 'subtract', 'multiply', 'true_divide', 'floor_divide', ) if not PY3: binary_ufuncs_arithmetic = binary_ufuncs_arithmetic + ('divide', ) #------------------------------------------------------------------------ # Register our type functions #------------------------------------------------------------------------ register_inferer(np, 'sum', reduce_) register_inferer(np, 'prod', reduce_) def register_arithmetic_ufunc(register_inferer, register_unbound, binary_ufunc): register_inferer(np, binary_ufunc, binary_map) register_unbound(np, binary_ufunc, "reduce", reduce_) register_unbound(np, binary_ufunc, "accumulate", accumulate) register_unbound(np, binary_ufunc, "reduceat", reduceat) register_unbound(np, binary_ufunc, "outer", outer) def register_bool_ufunc(register_inferer, register_unbound, binary_ufunc): register_inferer(np, binary_ufunc, binary_map_bool) register_unbound(np, binary_ufunc, "reduce", reduce_bool)
from functools import partial from numba.containers import typedlist from numba.containers import typedtuple from numba.containers import orderedcontainer from numba.type_inference.module_type_inference import register_inferer #----------------------------------------------------------------------- # Register type function for typedlist construction #----------------------------------------------------------------------- def infer_tlist(type_node, iterable_node): return orderedcontainer.typedcontainer_infer(typedlist.compile_typedlist, type_node, iterable_node) register_inferer(typedlist, 'typedlist', infer_tlist, pass_in_types=False) #----------------------------------------------------------------------- # Register type function for typedtuple construction #----------------------------------------------------------------------- def infer_ttuple(type_node, iterable_node): return orderedcontainer.typedcontainer_infer(typedtuple.compile_typedtuple, type_node, iterable_node) register_inferer(typedtuple, 'typedtuple', infer_ttuple, pass_in_types=False)
# Arithmetic ufuncs 'add', 'subtract', 'multiply', 'true_divide', 'floor_divide', ) if not PY3: binary_ufuncs_arithmetic = binary_ufuncs_arithmetic + ('divide', ) #------------------------------------------------------------------------ # Register our type functions #------------------------------------------------------------------------ register_inferer(np, 'sum', reduce_) register_inferer(np, 'prod', reduce_) def register_arithmetic_ufunc(register_inferer, register_unbound, binary_ufunc): register_inferer(np, binary_ufunc, binary_map) register_unbound(np, binary_ufunc, "reduce", reduce_) register_unbound(np, binary_ufunc, "accumulate", accumulate) register_unbound(np, binary_ufunc, "reduceat", reduceat) register_unbound(np, binary_ufunc, "outer", outer) def register_bool_ufunc(register_inferer, register_unbound, binary_ufunc): register_inferer(np, binary_ufunc, binary_map_bool) register_unbound(np, binary_ufunc, "reduce", reduce_bool) register_unbound(np, binary_ufunc, "accumulate", accumulate_bool) register_unbound(np, binary_ufunc, "reduceat", reduceat_bool) register_unbound(np, binary_ufunc, "outer", outer_bool)
from functools import partial from numba.containers import typedlist from numba.containers import typedtuple from numba.containers import orderedcontainer from numba.type_inference.module_type_inference import register_inferer #----------------------------------------------------------------------- # Register type function for typedlist construction #----------------------------------------------------------------------- def infer_tlist(type_node, iterable_node): return orderedcontainer.typedcontainer_infer( typedlist.compile_typedlist, type_node, iterable_node) register_inferer(typedlist, 'typedlist', infer_tlist, pass_in_types=False) #----------------------------------------------------------------------- # Register type function for typedtuple construction #----------------------------------------------------------------------- def infer_ttuple(type_node, iterable_node): return orderedcontainer.typedcontainer_infer( typedtuple.compile_typedtuple, type_node, iterable_node) register_inferer(typedtuple, 'typedtuple', infer_ttuple, pass_in_types=False)