def testEmptyExecution(self): t = empty((20, 30), dtype='i8', chunk_size=5) res = self.executor.execute_tensor(t, concat=True) self.assertEqual(res[0].shape, (20, 30)) self.assertEqual(res[0].dtype, np.int64) t = empty((20, 30), chunk_size=5) res = self.executor.execute_tensor(t, concat=True) self.assertEqual(res[0].shape, (20, 30)) self.assertEqual(res[0].dtype, np.float64) t2 = empty_like(t) res = self.executor.execute_tensor(t2, concat=True) self.assertEqual(res[0].shape, (20, 30)) self.assertEqual(res[0].dtype, np.float64)
def testEmptyExecution(self): t = empty((20, 30), dtype='i8', chunks=5) res = self.executor.execute_tensor(t, concat=True) self.assertEqual(res[0].shape, (20, 30)) self.assertEqual(res[0].dtype, np.int64) self.assertFalse(np.array_equal(res, np.zeros((20, 30)))) t = empty((20, 30), chunks=5) res = self.executor.execute_tensor(t, concat=True) self.assertFalse(np.allclose(res, np.zeros((20, 30)))) t2 = empty_like(t) res = self.executor.execute_tensor(t2, concat=True) self.assertEqual(res[0].shape, (20, 30)) self.assertEqual(res[0].dtype, np.float64)
def testLogWithOutWhere(self): t1 = ones((3, 4), chunk_size=2) t2 = log(t1, out=t1) self.assertIsInstance(t2.op, TensorLog) self.assertEqual(t1.op.out.key, t1.op.input.key) self.assertIs(t2, t1) self.assertEqual(t2.op.input.extra_params.raw_chunk_size, 2) self.assertNotEqual(t2.key, t2.op.input.key) t3 = empty((3, 4), chunk_size=2) t4 = log(t1, out=t3, where=t1 > 0) self.assertIsInstance(t4.op, TensorLog) self.assertIs(t4, t3) self.assertEqual(t2.op.input.extra_params.raw_chunk_size, 2) self.assertNotEqual(t2.key, t2.op.input.key)
def testDatatimeArith(self): t1 = array([np.datetime64('2005-02-02'), np.datetime64('2005-02-03')]) t2 = t1 + np.timedelta64(1) self.assertIsInstance(t2.op, AddConstant) t3 = t1 - np.datetime64('2005-02-02') self.assertIsInstance(t3.op, SubConstant) 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 testFrexp(self): t1 = ones((3, 4, 5), chunk_size=2) t2 = empty((3, 4, 5), dtype=np.float_, chunk_size=2) op_type = type(t1.op) o1, o2 = frexp(t1) self.assertIs(o1.op, o2.op) self.assertNotEqual(o1.dtype, o2.dtype) o1, o2 = frexp(t1, t1) self.assertIs(o1, t1) self.assertIsNot(o1.inputs[0], t1) self.assertIsInstance(o1.inputs[0].op, op_type) self.assertIsNot(o2.inputs[0], t1) o1, o2 = frexp(t1, t2, where=t1 > 0) op_type = type(t2.op) self.assertIs(o1, t2) self.assertIsNot(o1.inputs[0], t1) self.assertIsInstance(o1.inputs[0].op, op_type) self.assertIsNot(o2.inputs[0], t1)