<s> """<STR_LIT>""" <EOL> from __future__ import print_function , division , absolute_import <EOL> from itertools import product <EOL> from numba import npdatetime , types <EOL> from numba . utils import PYVERSION <EOL> from numba . typing . templates import ( AttributeTemplate , ConcreteTemplate , <EOL> AbstractTemplate , infer_global , infer , <EOL> infer_getattr , signature ) <EOL> class TimedeltaUnaryOp ( AbstractTemplate ) : <EOL> def generic ( self , args , kws ) : <EOL> if len ( args ) == <NUM_LIT:2> : <EOL> return <EOL> op , = args <EOL> if not isinstance ( op , types . NPTimedelta ) : <EOL> return <EOL> return signature ( op , op ) <EOL> class TimedeltaBinOp ( AbstractTemplate ) : <EOL> def generic ( self , args , kws ) : <EOL> if len ( args ) == <NUM_LIT:1> : <EOL> return <EOL> left , right = args <EOL> if not all ( isinstance ( tp , types . NPTimedelta ) for tp in args ) : <EOL> return <EOL> if npdatetime . can_cast_timedelta_units ( left . unit , right . unit ) : <EOL> return signature ( right , left , right ) <EOL> elif npdatetime . can_cast_timedelta_units ( right . unit , left . unit ) : <EOL> return signature ( left , left , right ) <EOL> class TimedeltaCmpOp ( AbstractTemplate ) : <EOL> def generic ( self , args , kws ) : <EOL> left , right = args <EOL> if not all ( isinstance ( tp , types . NPTimedelta ) for tp in args ) : <EOL> return <EOL> return signature ( types . boolean , left , right ) <EOL> class TimedeltaOrderedCmpOp ( AbstractTemplate ) : <EOL> def generic ( self , args , kws ) : <EOL> left , right = args <EOL> if not all ( isinstance ( tp , types . NPTimedelta ) for tp in args ) : <EOL> return <EOL> if ( npdatetime . can_cast_timedelta_units ( left . unit , right . unit ) or <EOL> npdatetime . can_cast_timedelta_units ( right . unit , left . unit ) ) : <EOL> return signature ( types . boolean , left , right ) <EOL> class TimedeltaMixOp ( AbstractTemplate ) : <EOL> def generic ( self , args , kws ) : <EOL> """<STR_LIT>""" <EOL> left , right = args <EOL> if isinstance ( right , types . NPTimedelta ) : <EOL> td , other = right , left <EOL> sig_factory = lambda other : signature ( td , other , td ) <EOL> elif isinstance ( left , types . NPTimedelta ) : <EOL> td , other = left , right <EOL> sig_factory = lambda other : signature ( td , td , other ) <EOL> else : <EOL> return <EOL> if not isinstance ( other , ( types . Float , types . Integer ) ) : <EOL> return <EOL> if isinstance ( other , types . Integer ) : <EOL> other = types . int64 <EOL> return sig_factory ( other ) <EOL> class TimedeltaDivOp ( AbstractTemplate ) : <EOL> def generic ( self , args , kws ) : <EOL> """<STR_LIT>""" <EOL> left , right = args <EOL> if not isinstance ( left , types . NPTimedelta ) : <EOL> return <EOL> if isinstance ( right , types . NPTimedelta ) : <EOL> if ( npdatetime . can_cast_timedelta_units ( left . unit , right . unit ) <EOL> or npdatetime . can_cast_timedelta_units ( right . unit , left . unit ) ) : <EOL> return signature ( types . float64 , left , right ) <EOL> elif isinstance ( right , ( types . Float ) ) : <EOL> return signature ( left , left , right ) <EOL> elif isinstance ( right , ( types . Integer ) ) : <EOL> return signature ( left , left , types . int64 ) <EOL> @ infer <EOL> class TimedeltaUnaryPos ( TimedeltaUnaryOp ) : <EOL> key = "<STR_LIT:+>" <EOL> @ infer <EOL> class TimedeltaUnaryNeg ( TimedeltaUnaryOp ) : <EOL> key = "<STR_LIT:->" <EOL> @ infer <EOL> class TimedeltaBinAdd ( TimedeltaBinOp ) : <EOL> key = "<STR_LIT:+>" <EOL> @ infer <EOL> class TimedeltaBinSub ( TimedeltaBinOp ) : <EOL> key = "<STR_LIT:->" <EOL> @ infer <EOL> class TimedeltaBinMult ( TimedeltaMixOp ) : <EOL> key = "<STR_LIT:*>" <EOL> @ infer <EOL> class TimedeltaTrueDiv ( TimedeltaDivOp ) : <EOL> key = "<STR_LIT:/>" <EOL> @ infer <EOL> class TimedeltaFloorDiv ( TimedeltaDivOp ) : <EOL> key = "<STR_LIT>" <EOL> @ infer <EOL> class TimedeltaLegacyDiv ( TimedeltaDivOp ) : <EOL> key = "<STR_LIT>" <EOL> @ infer <EOL> class TimedeltaCmpEq ( TimedeltaCmpOp ) : <EOL> key = '<STR_LIT>' <EOL> @ infer <EOL> class TimedeltaCmpNe ( TimedeltaCmpOp ) : <EOL> key = '<STR_LIT>' <EOL> @ infer <EOL> class TimedeltaCmpLt ( TimedeltaOrderedCmpOp ) : <EOL> key = '<STR_LIT:<>' <EOL> @ infer <EOL> class TimedeltaCmpLE ( TimedeltaOrderedCmpOp ) : <EOL> key = '<STR_LIT>' <EOL> @ infer <EOL> class TimedeltaCmpGt ( TimedeltaOrderedCmpOp ) : <EOL> key = '<STR_LIT:>>' <EOL> @ infer <EOL> class TimedeltaCmpGE ( TimedeltaOrderedCmpOp ) : <EOL> key = '<STR_LIT>' <EOL> @ infer_global ( abs ) <EOL> class TimedeltaAbs ( TimedeltaUnaryOp ) : <EOL> pass <EOL> @ infer <EOL> class DatetimePlusTimedelta ( AbstractTemplate ) : <EOL> key = '<STR_LIT:+>' <EOL> def generic ( self , args , kws ) : <EOL> if len ( args ) == <NUM_LIT:1> : <EOL> return <EOL> left , right = args <EOL> if isinstance ( right , types . NPTimedelta ) : <EOL> dt = left <EOL> td = right <EOL> elif isinstance ( left , types . NPTimedelta ) : <EOL> dt = right <EOL> td = left <EOL> else : <EOL> return <EOL> if isinstance ( dt , types . NPDatetime ) : <EOL> unit = npdatetime . combine_datetime_timedelta_units ( dt . unit , td . unit ) <EOL> if unit is not None : <EOL> return signature ( types . NPDatetime ( unit ) , left , right ) <EOL> @ infer <EOL> class DatetimeMinusTimedelta ( AbstractTemplate ) : <EOL> key = '<STR_LIT:->' <EOL> def generic ( self , args , kws ) : <EOL> if len ( args ) == <NUM_LIT:1> : <EOL> return <EOL> dt , td = args <EOL> if isinstance ( dt , types . NPDatetime ) and isinstance ( td , types . NPTimedelta ) : <EOL> unit = npdatetime . combine_datetime_timedelta_units ( dt . unit , td . unit ) <EOL> if unit is not None : <EOL> return signature ( types . NPDatetime ( unit ) , dt , td ) <EOL> @ infer <EOL> class DatetimeMinusDatetime ( AbstractTemplate ) : <EOL> key = '<STR_LIT:->' <EOL> def generic ( self , args , kws ) : <EOL> if len ( args ) == <NUM_LIT:1> : <EOL> return <EOL> left , right = args <EOL> if isinstance ( left , types . NPDatetime ) and isinstance ( right , types . NPDatetime ) : <EOL> unit = npdatetime . get_best_unit ( left . unit , right . unit ) <EOL> return signature ( types . NPTimedelta ( unit ) , left , right ) <EOL> class DatetimeCmpOp ( AbstractTemplate ) : <EOL> def generic ( self , args , kws ) : <EOL> left , right = args <EOL> if not all ( isinstance ( tp , types . NPDatetime ) for tp in args ) : <EOL> return <EOL> return signature ( types . boolean , left , right ) <EOL> @ infer <EOL> class DatetimeCmpEq ( DatetimeCmpOp ) : <EOL> key = '<STR_LIT>' <EOL> @ infer <EOL> class DatetimeCmpNe ( DatetimeCmpOp ) : <EOL> key = '<STR_LIT>' <EOL> @ infer <EOL> class DatetimeCmpLt ( DatetimeCmpOp ) : <EOL> key = '<STR_LIT:<>' <EOL> @ infer <EOL> class DatetimeCmpLE ( DatetimeCmpOp ) : <EOL> key = '<STR_LIT>' <EOL> @ infer <EOL> class DatetimeCmpGt ( DatetimeCmpOp ) : <EOL> key = '<STR_LIT:>>' <EOL> @ infer <EOL> class DatetimeCmpGE ( DatetimeCmpOp ) : <EOL> key = '<STR_LIT>' </s>
