MCPcopy Index your code
hub / github.com/python/cpython / test_ndarray_slice_multidim

Method test_ndarray_slice_multidim

Lib/test/test_buffer.py:1745–1775  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1743 self.assertEqual(x.tolist(), carray(items, [3, 4]))
1744
1745 def test_ndarray_slice_multidim(self):
1746 shape_t = (2, 3, 5)
1747 ndim = len(shape_t)
1748 nitems = prod(shape_t)
1749 for shape in permutations(shape_t):
1750
1751 fmt, items, _ = randitems(nitems)
1752 itemsize = struct.calcsize(fmt)
1753
1754 for flags in (0, ND_PIL):
1755 nd = ndarray(items, shape=shape, format=fmt, flags=flags)
1756 lst = carray(items, shape)
1757
1758 for slices in rslices_ndim(ndim, shape):
1759
1760 listerr = None
1761 try:
1762 sliced = multislice(lst, slices)
1763 except Exception as e:
1764 listerr = e.__class__
1765
1766 nderr = None
1767 try:
1768 ndsliced = nd[slices]
1769 except Exception as e:
1770 nderr = e.__class__
1771
1772 if nderr or listerr:
1773 self.assertIs(nderr, listerr)
1774 else:
1775 self.assertEqual(ndsliced.tolist(), sliced)
1776
1777 def test_ndarray_slice_redundant_suboffsets(self):
1778 shape_t = (2, 3, 5, 2)

Callers

nothing calls this directly

Calls 7

randitemsFunction · 0.85
carrayFunction · 0.85
rslices_ndimFunction · 0.85
multisliceFunction · 0.85
prodFunction · 0.70
assertIsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected