@@ -87,7 +87,7 @@ cdef class _Timestamp(datetime):
87
87
return PyObject_RichCompareBool(val, other, op)
88
88
89
89
try :
90
- ots = self . __class__ (other)
90
+ ots = type ( self ) (other)
91
91
except ValueError :
92
92
return self ._compare_outside_nanorange(other, op)
93
93
else :
@@ -96,7 +96,7 @@ cdef class _Timestamp(datetime):
96
96
if ndim != - 1 :
97
97
if ndim == 0 :
98
98
if is_datetime64_object(other):
99
- other = self . __class__ (other)
99
+ other = type ( self ) (other)
100
100
elif is_array(other):
101
101
# zero-dim array, occurs if try comparison with
102
102
# datetime64 scalar on the left hand side
@@ -105,7 +105,7 @@ cdef class _Timestamp(datetime):
105
105
# the numpy C api to extract it.
106
106
other = cnp.PyArray_ToScalar(cnp.PyArray_DATA(other),
107
107
other)
108
- other = self . __class__ (other)
108
+ other = type ( self ) (other)
109
109
else :
110
110
return NotImplemented
111
111
elif is_array(other):
@@ -226,8 +226,7 @@ cdef class _Timestamp(datetime):
226
226
227
227
if is_timedelta64_object(other):
228
228
other_int = other.astype(' timedelta64[ns]' ).view(' i8' )
229
- return self .__class__ (self .value + other_int,
230
- tz = self .tzinfo, freq = self .freq)
229
+ return type (self )(self .value + other_int, tz = self .tzinfo, freq = self .freq)
231
230
232
231
elif is_integer_object(other):
233
232
maybe_integer_op_deprecated(self )
@@ -238,8 +237,7 @@ cdef class _Timestamp(datetime):
238
237
elif self .freq is None :
239
238
raise NullFrequencyError(
240
239
" Cannot add integral value to Timestamp without freq." )
241
- return self .__class__ ((self .freq * other).apply(self ),
242
- freq = self .freq)
240
+ return type (self )((self .freq * other).apply(self ), freq = self .freq)
243
241
244
242
elif PyDelta_Check(other) or hasattr (other, ' delta' ):
245
243
# delta --> offsets.Tick
@@ -253,8 +251,7 @@ cdef class _Timestamp(datetime):
253
251
other.seconds * 1000000 +
254
252
other.microseconds) * 1000
255
253
256
- result = self .__class__ (self .value + nanos,
257
- tz = self .tzinfo, freq = self .freq)
254
+ result = type (self )(self .value + nanos, tz = self .tzinfo, freq = self .freq)
258
255
return result
259
256
260
257
elif is_array(other):
@@ -272,7 +269,7 @@ cdef class _Timestamp(datetime):
272
269
273
270
result = datetime.__add__ (self , other)
274
271
if PyDateTime_Check(result):
275
- result = self . __class__ (result)
272
+ result = type ( self ) (result)
276
273
result.nanosecond = self .nanosecond
277
274
return result
278
275
@@ -304,9 +301,9 @@ cdef class _Timestamp(datetime):
304
301
if (PyDateTime_Check(self )
305
302
and (PyDateTime_Check(other) or is_datetime64_object(other))):
306
303
if isinstance (self , _Timestamp):
307
- other = self . __class__ (other)
304
+ other = type ( self ) (other)
308
305
else :
309
- self = other. __class__ (self )
306
+ self = type ( other) (self )
310
307
311
308
# validate tz's
312
309
if not tz_compare(self .tzinfo, other.tzinfo):
0 commit comments