def testDatatimeArith(self): t1 = array([np.datetime64('2005-02-02'), np.datetime64('2005-02-03')]) t2 = t1 + np.timedelta64(1) self.assertIsInstance(t2.op, TensorAdd) t3 = t1 - np.datetime64('2005-02-02') self.assertIsInstance(t3.op, TensorSubtract) self.assertEqual(t3.dtype, (np.array(['2005-02-02', '2005-02-03'], dtype=np.datetime64) - np.datetime64('2005-02-02')).dtype) t1 = array([np.datetime64('2005-02-02'), np.datetime64('2005-02-03')]) subtract(t1, np.datetime64('2005-02-02'), out=empty(t1.shape, dtype=t3.dtype)) t1 = array([np.datetime64('2005-02-02'), np.datetime64('2005-02-03')]) add(t1, np.timedelta64(1, 'D'), out=t1)
def test_datatime_arith(): t1 = array([np.datetime64('2005-02-02'), np.datetime64('2005-02-03')]) t2 = t1 + np.timedelta64(1) assert isinstance(t2.op, TensorAdd) t3 = t1 - np.datetime64('2005-02-02') assert isinstance(t3.op, TensorSubtract) assert t3.dtype == ( np.array(['2005-02-02', '2005-02-03'], dtype=np.datetime64) - np.datetime64('2005-02-02')).dtype t1 = array([np.datetime64('2005-02-02'), np.datetime64('2005-02-03')]) subtract(t1, np.datetime64('2005-02-02'), out=empty(t1.shape, dtype=t3.dtype)) t1 = array([np.datetime64('2005-02-02'), np.datetime64('2005-02-03')]) add(t1, np.timedelta64(1, 'D'), out=t1)