Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 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)