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