Пример #1
0
 def impl(context, builder, sig, args):
     va, vb = args
     ta, tb = sig.args
     unit_a = ta.unit
     unit_b = tb.unit
     ret_unit = npdatetime.get_best_unit(unit_a, unit_b)
     ret = alloc_boolean_result(builder)
     with builder.if_else(are_not_nat(builder,
                                      [va, vb])) as (then, otherwise):
         with then:
             norm_a = convert_datetime_for_arith(builder, va, unit_a,
                                                 ret_unit)
             norm_b = convert_datetime_for_arith(builder, vb, unit_b,
                                                 ret_unit)
             ret_val = builder.icmp(ll_op, norm_a, norm_b)
             builder.store(ret_val, ret)
         with otherwise:
             if numpy_support.numpy_version < (1, 16):
                 # No scaling when comparing NaTs
                 ret_val = builder.icmp(ll_op, va, vb)
             else:
                 if ll_op == lc.ICMP_NE:
                     ret_val = cgutils.true_bit
                 else:
                     ret_val = cgutils.false_bit
             builder.store(ret_val, ret)
     res = builder.load(ret)
     return impl_ret_untracked(context, builder, sig.return_type, res)
Пример #2
0
 def impl(context, builder, sig, args):
     va, vb = args
     ta, tb = sig.args
     unit_a = ta.unit
     unit_b = tb.unit
     ret_unit = npdatetime.get_best_unit(unit_a, unit_b)
     ret = alloc_boolean_result(builder)
     with builder.if_else(are_not_nat(builder, [va, vb])) as (then, otherwise):
         with then:
             norm_a = convert_datetime_for_arith(
                 builder, va, unit_a, ret_unit)
             norm_b = convert_datetime_for_arith(
                 builder, vb, unit_b, ret_unit)
             ret_val = builder.icmp(ll_op, norm_a, norm_b)
             builder.store(ret_val, ret)
         with otherwise:
             if numpy_support.version < (1, 16):
                 # No scaling when comparing NaTs
                 ret_val = builder.icmp(ll_op, va, vb)
             else:
                 if ll_op == lc.ICMP_NE:
                     ret_val = cgutils.true_bit
                 else:
                     ret_val = cgutils.false_bit
             builder.store(ret_val, ret)
     res = builder.load(ret)
     return impl_ret_untracked(context, builder, sig.return_type, res)
Пример #3
0
 def generic(self, args, kws):
     if len(args) == 1:
         # Guard against unary -
         return
     left, right = args
     if isinstance(left, types.NPDatetime) and isinstance(right, types.NPDatetime):
         # All units compatible! Yoohoo!
         unit = npdatetime.get_best_unit(left.unit, right.unit)
         return signature(types.NPTimedelta(unit), left, right)
Пример #4
0
 def generic(self, args, kws):
     if len(args) == 1:
         # Guard against unary -
         return
     left, right = args
     if isinstance(left, types.NPDatetime) and isinstance(right, types.NPDatetime):
         # All units compatible! Yoohoo!
         unit = npdatetime.get_best_unit(left.unit, right.unit)
         return signature(types.NPTimedelta(unit), left, right)
Пример #5
0
 def impl(context, builder, sig, args):
     va, vb = args
     ta, tb = sig.args
     unit_a = ta.unit
     unit_b = tb.unit
     ret_unit = npdatetime.get_best_unit(unit_a, unit_b)
     ret = alloc_boolean_result(builder)
     with builder.if_else(are_not_nat(builder, [va, vb])) as (then, otherwise):
         with then:
             norm_a = convert_datetime_for_arith(builder, va, unit_a, ret_unit)
             norm_b = convert_datetime_for_arith(builder, vb, unit_b, ret_unit)
             ret_val = builder.icmp(ll_op, norm_a, norm_b)
             builder.store(ret_val, ret)
         with otherwise:
             # No scaling when comparing NaTs
             ret_val = builder.icmp(ll_op, va, vb)
             builder.store(ret_val, ret)
     return builder.load(ret)
Пример #6
0
 def impl(context, builder, sig, args):
     va, vb = args
     ta, tb = sig.args
     unit_a = ta.unit
     unit_b = tb.unit
     ret_unit = npdatetime.get_best_unit(unit_a, unit_b)
     ret = alloc_boolean_result(builder)
     with cgutils.ifelse(builder,
                         are_not_nat(builder, [va, vb])) as (then, otherwise):
         with then:
             norm_a = convert_datetime_for_arith(builder, va, unit_a, ret_unit)
             norm_b = convert_datetime_for_arith(builder, vb, unit_b, ret_unit)
             ret_val = builder.icmp(ll_op, norm_a, norm_b)
             builder.store(ret_val, ret)
         with otherwise:
             # No scaling when comparing NaTs
             ret_val = builder.icmp(ll_op, va, vb)
             builder.store(ret_val, ret)
     return builder.load(ret)