from __future__ import print_function, absolute_import from collections import namedtuple import ctypes import enum import numpy as np from numba import numpy_support, types, utils, smartarray from numba import errors # terminal color markup _termcolor = errors.termcolor() class Purpose(enum.Enum): # Value being typed is used as an argument argument = 1 # Value being typed is used as a constant constant = 2 _TypeofContext = namedtuple("_TypeofContext", ("purpose",)) def typeof(val, purpose=Purpose.argument): """ Get the Numba type of a Python value for the given purpose. """ # Note the behaviour for Purpose.argument must match _typeof.c. c = _TypeofContext(purpose) ty = typeof_impl(val, c) if ty is None:
from __future__ import print_function, division, absolute_import import traceback from .abstract import Callable, DTypeSpec, Dummy, Literal, Type, weakref from .common import Opaque from .misc import unliteral from numba import errors # terminal color markup _termcolor = errors.termcolor() class _ResolutionFailures(object): """Collect and format function resolution failures. """ def __init__(self, context, function_type, args, kwargs): self._context = context self._function_type = function_type self._args = args self._kwargs = kwargs self._failures = [] def __len__(self): return len(self._failures) def add_error(self, calltemplate, error): """ Args ---- calltemplate : CallTemplate