def test_always_slices(self): array = biggus.ConstantArray((3, 5), dtype=np.float32) chunk_size = 5 - 1 with set_chunk_size(chunk_size): slices = _all_slices_inner(array.shape, always_slices=True) expected = [[slice(0, 1, None), slice(1, 2, None), slice(2, 3, None)], [slice(0, 4, None), slice(4, 5, None)]] self.assertEqual(slices, expected)
def test(self): shape = (3, 5, 10) a = biggus.ConstantArray(shape, dtype=np.float32) b = biggus.ConstantArray(shape, dtype=np.float64) with set_chunk_size(32//8*10-1): result = biggus.sum(a * b, axis=0).ndarray() self.assertEqual(result.shape, shape[1:])
def test(self): shape = (3, 5, 10) a = biggus.ConstantArray(shape, dtype=np.float32) b = biggus.ConstantArray(shape, dtype=np.float64) with set_chunk_size(32 // 8 * 10 - 1): result = biggus.sum(a * b, axis=0).ndarray() self.assertEqual(result.shape, shape[1:])
def test_all_cases(self): array = biggus.ConstantArray((4, 3, 5), dtype=np.float32) # Chunk size set to fit in two items from the second dimension into a # single chunk, but not the whole dimension. chunk_size = 5 * 3 - 1 with set_chunk_size(chunk_size): slices = _all_slices(array) expected = [[0, 1, 2, 3], [slice(0, 2, None), slice(2, 3, None)], (slice(None, None, None),)] self.assertEqual(slices, expected)