def typeof_const(self, inst, target, const): ty = self.resolve_value_type(inst, const) # Special case string constant as Const type if ty == types.string: ty = types.Const(value=const) self.lock_type(target.name, ty, loc=inst.loc, literal_value=const)
def generic(self, args, kws): # Resolution of members for record and structured arrays record, idx, value = args if isinstance(record, types.Record) and isinstance(idx, str): expectedty = record.typeof(idx) if self.context.can_convert(value, expectedty) is not None: return signature(types.void, record, types.Const(idx), value)
def resolve_kind(self, ary): if isinstance(ary.key, types.scalars.Float): val = 'f' elif isinstance(ary.key, types.scalars.Integer): val = 'i' else: return None # other types not supported yet return types.Const(val)
def resolve_argsort(self, ary, args, kws): assert not args kwargs = dict(kws) kind = kwargs.pop('kind', types.Const('quicksort')) if kwargs: msg = "Unsupported keywords: {!r}" raise TypingError(msg.format([k for k in kwargs.keys()])) if ary.ndim == 1: def argsort_stub(kind='quicksort'): pass pysig = utils.pysignature(argsort_stub) sig = signature(types.Array(types.intp, 1, 'C'), kind).replace(pysig=pysig) return sig
def getone(self, get_literals=False): assert self.type is not None if self.literal_value is not NOTSET and get_literals: return types.Const(self.literal_value) return self.type
def getone(self, get_literals=False): if self.type is None: raise TypingError("Undecided type {}".format(self)) if self.literal_value is not NOTSET and get_literals: return types.Const(self.literal_value) return self.type
def resolve_dropna(self, ary, args, kws): out = ary # output is None for inplace case if 'inplace' in kws and kws['inplace'] == types.Const(True): out = types.none return signature(out, *args)