test_datetime.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:radar 作者: amoose136 项目源码 文件源码
def test_datetime_compare_nat(self):
        dt_nat = np.datetime64('NaT', 'D')
        dt_other = np.datetime64('2000-01-01')
        td_nat = np.timedelta64('NaT', 'h')
        td_other = np.timedelta64(1, 'h')

        for op in [np.equal, np.less, np.less_equal,
                   np.greater, np.greater_equal]:
            if op(dt_nat, dt_nat):
                assert_warns(FutureWarning, op, dt_nat, dt_nat)
            if op(dt_nat, dt_other):
                assert_warns(FutureWarning, op, dt_nat, dt_other)
            if op(dt_other, dt_nat):
                assert_warns(FutureWarning, op, dt_other, dt_nat)
            if op(td_nat, td_nat):
                assert_warns(FutureWarning, op, td_nat, td_nat)
            if op(td_nat, td_other):
                assert_warns(FutureWarning, op, td_nat, td_other)
            if op(td_other, td_nat):
                assert_warns(FutureWarning, op, td_other, td_nat)

        assert_warns(FutureWarning, np.not_equal, dt_nat, dt_nat)
        assert_(np.not_equal(dt_nat, dt_other))
        assert_(np.not_equal(dt_other, dt_nat))
        assert_warns(FutureWarning, np.not_equal, td_nat, td_nat)
        assert_(np.not_equal(td_nat, td_other))
        assert_(np.not_equal(td_other, td_nat))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号