def __array_wrap__(self, result, context=None):
"""
Gets called after a ufunc. Needs additional handling as
PeriodIndex stores internal data as int dtype
Replace this to __numpy_ufunc__ in future version
"""
if isinstance(context, tuple) and len(context) > 0:
func = context[0]
if (func is np.add):
return self._add_delta(context[1][1])
elif (func is np.subtract):
return self._add_delta(-context[1][1])
elif isinstance(func, np.ufunc):
if 'M->M' not in func.types:
msg = "ufunc '{0}' not supported for the PeriodIndex"
# This should be TypeError, but TypeError cannot be raised
# from here because numpy catches.
raise ValueError(msg.format(func.__name__))
if com.is_bool_dtype(result):
return result
return PeriodIndex(result, freq=self.freq, name=self.name)
period.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录