當前位置: 首頁>>代碼示例>>Python>>正文


Python dummyarray.Array類代碼示例

本文整理匯總了Python中numba.dummyarray.Array的典型用法代碼示例。如果您正苦於以下問題:Python Array類的具體用法?Python Array怎麽用?Python Array使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Array類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_extent_iter_2d

    def test_extent_iter_2d(self):
        nparr = np.empty((4, 5))
        arr = Array.from_desc(0, nparr.shape, nparr.strides,
                              nparr.dtype.itemsize)
        [ext] = list(arr.iter_contiguous_extent())
        self.assertEqual(ext, arr.extent)

        self.assertEqual(len(list(arr[::2].iter_contiguous_extent())), 2)
開發者ID:cpcloud,項目名稱:numba,代碼行數:8,代碼來源:test_dummyarray.py

示例2: test_reshape_3d1d

 def test_reshape_3d1d(self):
     nparr = np.empty((3, 4, 5))
     arr = Array.from_desc(0, nparr.shape, nparr.strides,
                           nparr.dtype.itemsize)
     expect = nparr.reshape(3 * 4 * 5)
     got = arr.reshape(3 * 4 * 5)[0]
     self.assertEqual(got.shape, expect.shape)
     self.assertEqual(got.strides, expect.strides)
開發者ID:cpcloud,項目名稱:numba,代碼行數:8,代碼來源:test_dummyarray.py

示例3: test_squeeze_invalid_axis

 def test_squeeze_invalid_axis(self):
     nparr = np.empty((1, 2, 1, 4, 1, 3))
     arr = Array.from_desc(
         0, nparr.shape, nparr.strides, nparr.dtype.itemsize
     )
     with self.assertRaises(ValueError):
         arr.squeeze(axis=1)
     with self.assertRaises(ValueError):
         arr.squeeze(axis=(2, 3))
開發者ID:numba,項目名稱:numba,代碼行數:9,代碼來源:test_dummyarray.py

示例4: test_slice2_1d

 def test_slice2_1d(self):
     nparr = np.empty(4)
     arr = Array.from_desc(0, nparr.shape, nparr.strides,
                           nparr.dtype.itemsize)
     xx = -2, -1, 0, 1, 2
     for x, y in itertools.product(xx, xx):
         expect = nparr[x:y]
         got = arr[x:y]
         self.assertSameContig(got, expect)
         self.assertEqual(got.shape, expect.shape)
         self.assertEqual(got.strides, expect.strides)
開發者ID:cpcloud,項目名稱:numba,代碼行數:11,代碼來源:test_dummyarray.py

示例5: test_slice1_1d

 def test_slice1_1d(self):
     nparr = np.empty(4)
     arr = Array.from_desc(0, nparr.shape, nparr.strides,
                           nparr.dtype.itemsize)
     xx = -2, -1, 0, 1, 2
     for x in xx:
         expect = nparr[:x]
         got = arr[:x]
         self.assertSameContig(got, expect)
         self.assertEqual(got.shape, expect.shape)
         self.assertEqual(got.strides, expect.strides)
開發者ID:cpcloud,項目名稱:numba,代碼行數:11,代碼來源:test_dummyarray.py

示例6: test_strided_3d

 def test_strided_3d(self):
     nparr = np.empty((4, 5, 6))
     arr = Array.from_desc(0, nparr.shape, nparr.strides,
                           nparr.dtype.itemsize)
     xx = -2, -1, 1, 2
     for a, b, c in itertools.product(xx, xx, xx):
         expect = nparr[::a, ::b, ::c]
         got = arr[::a, ::b, ::c]
         self.assertSameContig(got, expect)
         self.assertEqual(got.shape, expect.shape)
         self.assertEqual(got.strides, expect.strides)
開發者ID:numba,項目名稱:numba,代碼行數:11,代碼來源:test_dummyarray.py

示例7: test_squeeze

 def test_squeeze(self):
     nparr = np.empty((1, 2, 1, 4, 1, 3))
     arr = Array.from_desc(
         0, nparr.shape, nparr.strides, nparr.dtype.itemsize
     )
     def _assert_equal_shape_strides(arr1, arr2):
         self.assertEqual(arr1.shape, arr2.shape)
         self.assertEqual(arr1.strides, arr2.strides)
     _assert_equal_shape_strides(arr, nparr)
     _assert_equal_shape_strides(arr.squeeze()[0], nparr.squeeze())
     for axis in (0, 2, 4, (0, 2), (0, 4), (2, 4), (0, 2, 4)):
         _assert_equal_shape_strides(
             arr.squeeze(axis=axis)[0], nparr.squeeze(axis=axis)
         )
開發者ID:numba,項目名稱:numba,代碼行數:14,代碼來源:test_dummyarray.py

示例8: test_slice1_2d

    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)
開發者ID:cpcloud,項目名稱:numba,代碼行數:18,代碼來源:test_dummyarray.py

示例9: test_extent_2d

 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)
開發者ID:cpcloud,項目名稱:numba,代碼行數:6,代碼來源:test_dummyarray.py


注:本文中的numba.dummyarray.Array類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。