• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python dummyarray.Array类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python function_util.external_call函数代码示例发布时间:2022-05-27
下一篇:
Python decorators.jit函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap