(self)
| 2107 | self.assertTrue(cmp_contig(b'\x01', x)) |
| 2108 | |
| 2109 | def test_ndarray_hash(self): |
| 2110 | |
| 2111 | a = array.array('L', [1,2,3]) |
| 2112 | nd = ndarray(a) |
| 2113 | self.assertRaises(ValueError, hash, nd) |
| 2114 | |
| 2115 | # one-dimensional |
| 2116 | b = bytes(list(range(12))) |
| 2117 | |
| 2118 | nd = ndarray(list(range(12)), shape=[12]) |
| 2119 | self.assertEqual(hash(nd), hash(b)) |
| 2120 | |
| 2121 | # C-contiguous |
| 2122 | nd = ndarray(list(range(12)), shape=[3,4]) |
| 2123 | self.assertEqual(hash(nd), hash(b)) |
| 2124 | |
| 2125 | nd = ndarray(list(range(12)), shape=[3,2,2]) |
| 2126 | self.assertEqual(hash(nd), hash(b)) |
| 2127 | |
| 2128 | # Fortran contiguous |
| 2129 | b = bytes(transpose(list(range(12)), shape=[4,3])) |
| 2130 | nd = ndarray(list(range(12)), shape=[3,4], flags=ND_FORTRAN) |
| 2131 | self.assertEqual(hash(nd), hash(b)) |
| 2132 | |
| 2133 | b = bytes(transpose(list(range(12)), shape=[2,3,2])) |
| 2134 | nd = ndarray(list(range(12)), shape=[2,3,2], flags=ND_FORTRAN) |
| 2135 | self.assertEqual(hash(nd), hash(b)) |
| 2136 | |
| 2137 | # suboffsets |
| 2138 | b = bytes(list(range(12))) |
| 2139 | nd = ndarray(list(range(12)), shape=[2,2,3], flags=ND_PIL) |
| 2140 | self.assertEqual(hash(nd), hash(b)) |
| 2141 | |
| 2142 | # non-byte formats |
| 2143 | nd = ndarray(list(range(12)), shape=[2,2,3], format='L') |
| 2144 | self.assertEqual(hash(nd), hash(nd.tobytes())) |
| 2145 | |
| 2146 | def test_py_buffer_to_contiguous(self): |
| 2147 |
nothing calls this directly
no test coverage detected