def test_asfortranarray(): # dtype different raw_a = np.random.rand(2, 4) raw_b = np.asfortranarray(raw_a, dtype='f4') a = tensor(raw_a, chunk_size=2) b = asfortranarray(a, dtype='f4') assert a.dtype == raw_a.dtype assert a.flags['C_CONTIGUOUS'] == raw_a.flags['C_CONTIGUOUS'] assert a.flags['F_CONTIGUOUS'] == raw_a.flags['F_CONTIGUOUS'] assert b.dtype == raw_b.dtype assert b.flags['C_CONTIGUOUS'] == raw_b.flags['C_CONTIGUOUS'] assert b.flags['F_CONTIGUOUS'] == raw_b.flags['F_CONTIGUOUS'] # no copy raw_a = np.asfortranarray(np.random.rand(2, 4)) raw_b = np.asfortranarray(raw_a) a = tensor(raw_a, chunk_size=2) b = asfortranarray(a) assert a.dtype == raw_a.dtype assert a.flags['C_CONTIGUOUS'] == raw_a.flags['C_CONTIGUOUS'] assert a.flags['F_CONTIGUOUS'] == raw_a.flags['F_CONTIGUOUS'] assert b.dtype == raw_b.dtype assert b.flags['C_CONTIGUOUS'] == raw_b.flags['C_CONTIGUOUS'] assert b.flags['F_CONTIGUOUS'] == raw_b.flags['F_CONTIGUOUS']
def testAsfortranarray(self): # dtype different raw_a = np.random.rand(2, 4) raw_b = np.asfortranarray(raw_a, dtype='f4') a = tensor(raw_a, chunk_size=2) b = asfortranarray(a, dtype='f4') self.assertEqual(a.dtype, raw_a.dtype) self.assertEqual(a.flags['C_CONTIGUOUS'], raw_a.flags['C_CONTIGUOUS']) self.assertEqual(a.flags['F_CONTIGUOUS'], raw_a.flags['F_CONTIGUOUS']) self.assertEqual(b.dtype, raw_b.dtype) self.assertEqual(b.flags['C_CONTIGUOUS'], raw_b.flags['C_CONTIGUOUS']) self.assertEqual(b.flags['F_CONTIGUOUS'], raw_b.flags['F_CONTIGUOUS']) # no copy raw_a = np.asfortranarray(np.random.rand(2, 4)) raw_b = np.asfortranarray(raw_a) a = tensor(raw_a, chunk_size=2) b = asfortranarray(a) self.assertEqual(a.dtype, raw_a.dtype) self.assertEqual(a.flags['C_CONTIGUOUS'], raw_a.flags['C_CONTIGUOUS']) self.assertEqual(a.flags['F_CONTIGUOUS'], raw_a.flags['F_CONTIGUOUS']) self.assertEqual(b.dtype, raw_b.dtype) self.assertEqual(b.flags['C_CONTIGUOUS'], raw_b.flags['C_CONTIGUOUS']) self.assertEqual(b.flags['F_CONTIGUOUS'], raw_b.flags['F_CONTIGUOUS'])