(self)
| 1897 | self.assertEqual(nd.tolist(), result) |
| 1898 | |
| 1899 | def test_ndarray_random(self): |
| 1900 | # construction of valid arrays |
| 1901 | for _ in range(ITERATIONS): |
| 1902 | for fmt in fmtdict['@']: |
| 1903 | itemsize = struct.calcsize(fmt) |
| 1904 | |
| 1905 | t = rand_structure(itemsize, True, maxdim=MAXDIM, |
| 1906 | maxshape=MAXSHAPE) |
| 1907 | self.assertTrue(verify_structure(*t)) |
| 1908 | items = randitems_from_structure(fmt, t) |
| 1909 | |
| 1910 | x = ndarray_from_structure(items, fmt, t) |
| 1911 | xlist = x.tolist() |
| 1912 | |
| 1913 | mv = memoryview(x) |
| 1914 | if is_memoryview_format(fmt): |
| 1915 | mvlist = mv.tolist() |
| 1916 | self.assertEqual(mvlist, xlist) |
| 1917 | |
| 1918 | if t[2] > 0: |
| 1919 | # ndim > 0: test against suboffsets representation. |
| 1920 | y = ndarray_from_structure(items, fmt, t, flags=ND_PIL) |
| 1921 | ylist = y.tolist() |
| 1922 | self.assertEqual(xlist, ylist) |
| 1923 | |
| 1924 | mv = memoryview(y) |
| 1925 | if is_memoryview_format(fmt): |
| 1926 | self.assertEqual(mv, y) |
| 1927 | mvlist = mv.tolist() |
| 1928 | self.assertEqual(mvlist, ylist) |
| 1929 | |
| 1930 | if numpy_array: |
| 1931 | shape = t[3] |
| 1932 | if 0 in shape: |
| 1933 | continue # https://github.com/numpy/numpy/issues/2503 |
| 1934 | z = numpy_array_from_structure(items, fmt, t) |
| 1935 | self.verify(x, obj=None, |
| 1936 | itemsize=z.itemsize, fmt=fmt, readonly=False, |
| 1937 | ndim=z.ndim, shape=z.shape, strides=z.strides, |
| 1938 | lst=z.tolist()) |
| 1939 | |
| 1940 | def test_ndarray_random_invalid(self): |
| 1941 | # exceptions during construction of invalid arrays |
nothing calls this directly
no test coverage detected