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_helpers.can_cast_timedelta_units(left.unit, right.unit) or npdatetime_helpers.can_cast_timedelta_units(right.unit, left.unit)): return signature(types.boolean, left, right)
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_helpers.can_cast_timedelta_units(left.unit, right.unit): return signature(right, left, right) elif npdatetime_helpers.can_cast_timedelta_units(right.unit, left.unit): return signature(left, left, right)
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_helpers.can_cast_timedelta_units(left.unit, right.unit) or npdatetime_helpers.can_cast_timedelta_units(right.unit, left.unit)): return signature(types.float64, left, right) elif isinstance(right, (types.Float)): return signature(left, left, right) elif isinstance(right, (types.Integer)): # Force integer types to convert to signed because it matches # timedelta64 semantics better. return signature(left, left, types.int64)