Beispiel #1
0
    def test_slice1_2d(self):
        nparr = np.empty((4, 5))
        arr = Array.from_desc(0, nparr.shape, nparr.strides,
                              nparr.dtype.itemsize)
        xx = -2, 0, 2
        for x in xx:
            expect = nparr[:x]
            got = arr[:x]
            self.assertEqual(got.shape, expect.shape)
            self.assertEqual(got.strides, expect.strides)
            self.assertSameContig(got, expect)

        for x, y in itertools.product(xx, xx):
            expect = nparr[:x, :y]
            got = arr[:x, :y]
            self.assertEqual(got.shape, expect.shape)
            self.assertEqual(got.strides, expect.strides)
            self.assertSameContig(got, expect)
Beispiel #2
0
 def test_extent_iter_1d(self):
     nparr = np.empty(4)
     arr = Array.from_desc(0, nparr.shape, nparr.strides,
                           nparr.dtype.itemsize)
     [ext] = list(arr.iter_contiguous_extent())
     self.assertEqual(ext, arr.extent)
Beispiel #3
0
 def test_extent_2d(self):
     nparr = np.empty((4, 5))
     arr = Array.from_desc(0, nparr.shape, nparr.strides,
                           nparr.dtype.itemsize)
     s, e = arr.extent
     self.assertEqual(e - s, nparr.size * nparr.dtype.itemsize)
Beispiel #4
0
 def test_issue_2766(self):
     z = np.empty((1, 2, 3))
     z = np.transpose(z, axes=(2, 0, 1))
     arr = Array.from_desc(0, z.shape, z.strides, z.itemsize)
     self.assertEqual(z.flags['C_CONTIGUOUS'], arr.flags['C_CONTIGUOUS'])
     self.assertEqual(z.flags['F_CONTIGUOUS'], arr.flags['F_CONTIGUOUS'])