Esempio n. 1
0
 def generic(self, args, kws):
     if len(args) == 1:
         # Guard against unary -
         return
     dt, td = args
     if isinstance(dt, types.NPDatetime) and isinstance(
             td, types.NPTimedelta):
         unit = npdatetime_helpers.combine_datetime_timedelta_units(
             dt.unit, td.unit)
         if unit is not None:
             return signature(types.NPDatetime(unit), dt, td)
Esempio n. 2
0
 def make_datetime_specific(outputs, dt_unit, td_unit):
     new_outputs = []
     for out in outputs:
         if isinstance(out, types.NPDatetime) and out.unit == "":
             unit = npdatetime_helpers.combine_datetime_timedelta_units(
                 dt_unit, td_unit)
             if unit is None:
                 raise TypeError(f"ufunc '{ufunc_name}' is not " +
                                 "supported between " +
                                 f"datetime64[{dt_unit}] " +
                                 f"and timedelta64[{td_unit}]")
             new_outputs.append(types.NPDatetime(unit))
         else:
             new_outputs.append(out)
     return new_outputs
Esempio n. 3
0
 def generic(self, args, kws):
     if len(args) == 1:
         # Guard against unary +
         return
     left, right = args
     if isinstance(right, types.NPTimedelta):
         dt = left
         td = right
     elif isinstance(left, types.NPTimedelta):
         dt = right
         td = left
     else:
         return
     if isinstance(dt, types.NPDatetime):
         unit = npdatetime_helpers.combine_datetime_timedelta_units(
             dt.unit, td.unit)
         if unit is not None:
             return signature(types.NPDatetime(unit), left, right)