def test_get_slice_2(): slice_ = Slice( origin=(1, 1, 1, 1), shape=(1, 1, 2, 2), ) data = np.arange(4 * 4 * 4 * 4).reshape(4, 4, 4, 4) assert slice_.get(data).shape == slice_.shape assert np.all(slice_.get(data) == np.array([[[ [85, 86], [89, 90], ]]]))
def _get_slice(self, slice: Slice): real_slice = slice.get() result = self._data[real_slice] # Defend against #1026 (internal bugs), allow deactivating in # optimized builds for performance assert result.shape == tuple(slice.shape) + self.extra_shape return result
def open_file(self): f = np.memmap(self._path, dtype=self.dtype, mode='r', shape=self._scan_size + self._detector_size_raw) ds_slice = Slice(origin=(0, 0, 0, 0), shape=self.shape) return f[ds_slice.get()] # crop off the two extra rows
def test_get_slice_1(): slice_ = Slice( origin=(0, 0, 0, 0), shape=(4, 4, 4, 4), ) assert slice_.get() == ( slice(0, 4), slice(0, 4), slice(0, 4), slice(0, 4), )