Exemple #1
0
 def generic(self, args, kws):
     # For ordered comparisons, units must be compatible
     left, right = args
     if not all(isinstance(tp, types.NPTimedelta) for tp in args):
         return
     if (npdatetime.can_cast_timedelta_units(left.unit, right.unit) or
         npdatetime.can_cast_timedelta_units(right.unit, left.unit)):
         return signature(types.boolean, left, right)
Exemple #2
0
 def generic(self, args, kws):
     # For ordered comparisons, units must be compatible
     left, right = args
     if not all(isinstance(tp, types.NPTimedelta) for tp in args):
         return
     if (npdatetime.can_cast_timedelta_units(left.unit, right.unit) or
         npdatetime.can_cast_timedelta_units(right.unit, left.unit)):
         return signature(types.boolean, left, right)
Exemple #3
0
 def generic(self, args, kws):
     if len(args) == 1:
         # Guard against unary + and -
         return
     left, right = args
     if not all(isinstance(tp, types.NPTimedelta) for tp in args):
         return
     if npdatetime.can_cast_timedelta_units(left.unit, right.unit):
         return signature(right, left, right)
     elif npdatetime.can_cast_timedelta_units(right.unit, left.unit):
         return signature(left, left, right)
Exemple #4
0
 def generic(self, args, kws):
     if len(args) == 1:
         # Guard against unary + and -
         return
     left, right = args
     if not all(isinstance(tp, types.NPTimedelta) for tp in args):
         return
     if npdatetime.can_cast_timedelta_units(left.unit, right.unit):
         return signature(right, left, right)
     elif npdatetime.can_cast_timedelta_units(right.unit, left.unit):
         return signature(left, left, right)
Exemple #5
0
 def generic(self, args, kws):
     """
     (timedelta64, {int, float}) -> timedelta64
     (timedelta64, timedelta64) -> float
     """
     left, right = args
     if not isinstance(left, types.NPTimedelta):
         return
     if isinstance(right, types.NPTimedelta):
         if (npdatetime.can_cast_timedelta_units(left.unit, right.unit)
             or npdatetime.can_cast_timedelta_units(right.unit, left.unit)):
             return signature(types.float64, left, right)
     # Force integer types to convert to signed because it matches
     # timedelta64 semantics better.
     elif right in types.signed_domain or right in types.real_domain:
         return signature(left, left, right)
Exemple #6
0
 def generic(self, args, kws):
     """
     (timedelta64, {int, float}) -> timedelta64
     (timedelta64, timedelta64) -> float
     """
     left, right = args
     if not isinstance(left, types.NPTimedelta):
         return
     if isinstance(right, types.NPTimedelta):
         if (npdatetime.can_cast_timedelta_units(left.unit, right.unit)
                 or npdatetime.can_cast_timedelta_units(
                     right.unit, left.unit)):
             return signature(types.float64, left, right)
     # Force integer types to convert to signed because it matches
     # timedelta64 semantics better.
     elif right in types.signed_domain or right in types.real_domain:
         return signature(left, left, right)