How to use the hub.bbox.Vec.zeros function in hub

To help you get started, we’ve selected a few hub examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github snarkai / Hub / hub / array.py View on Github external
res = np.amax(arr, axis=tuple(range(0, len(arr.shape) - 1)))
            assert len(res.shape) == 1
            assert len(_shape[s:]) == res.shape[0]
            _shape[s:] = res
            _shape = tuple(_shape)

        slices = Bbox(Vec.zeros(_shape), _shape).reify_slices(slices, bounded=True)
        requested_bbox = Bbox.from_slices(slices)

        # Make sure chunks fit
        full_bbox = requested_bbox.expand_to_chunk_size(
            self.chunk, offset=Vec.zeros(self.shape)
        )

        # Clamb the border
        full_bbox = Bbox.clamp(full_bbox, Bbox(Vec.zeros(self.shape), self.shape))

        # Generate chunknames
        cloudpaths = list(
            chunknames(
                full_bbox,
                self.shape,
                self._path,
                self.chunk,
                protocol="none",  # self.protocol
            )
        )

        return cloudpaths, requested_bbox
github snarkai / Hub / hub / array.py View on Github external
slices = (slices,)
        elif isinstance(slices, slice):
            slices = (slices,)
        slices = tuple(slices)

        _shape = list(self.shape)
        if self._darray is not None:
            s = len(self._darray.shape) - 1
            arr = self._darray[slices[:s]]
            res = np.amax(arr, axis=tuple(range(0, len(arr.shape) - 1)))
            assert len(res.shape) == 1
            assert len(_shape[s:]) == res.shape[0]
            _shape[s:] = res
            _shape = tuple(_shape)

        slices = Bbox(Vec.zeros(_shape), _shape).reify_slices(slices, bounded=True)
        requested_bbox = Bbox.from_slices(slices)

        # Make sure chunks fit
        full_bbox = requested_bbox.expand_to_chunk_size(
            self.chunk, offset=Vec.zeros(self.shape)
        )

        # Clamb the border
        full_bbox = Bbox.clamp(full_bbox, Bbox(Vec.zeros(self.shape), self.shape))

        # Generate chunknames
        cloudpaths = list(
            chunknames(
                full_bbox,
                self.shape,
                self._path,
github snarkai / Hub / hub / array.py View on Github external
_shape = list(self.shape)
        if self._darray is not None:
            s = len(self._darray.shape) - 1
            arr = self._darray[slices[:s]]
            res = np.amax(arr, axis=tuple(range(0, len(arr.shape) - 1)))
            assert len(res.shape) == 1
            assert len(_shape[s:]) == res.shape[0]
            _shape[s:] = res
            _shape = tuple(_shape)

        slices = Bbox(Vec.zeros(_shape), _shape).reify_slices(slices, bounded=True)
        requested_bbox = Bbox.from_slices(slices)

        # Make sure chunks fit
        full_bbox = requested_bbox.expand_to_chunk_size(
            self.chunk, offset=Vec.zeros(self.shape)
        )

        # Clamb the border
        full_bbox = Bbox.clamp(full_bbox, Bbox(Vec.zeros(self.shape), self.shape))

        # Generate chunknames
        cloudpaths = list(
            chunknames(
                full_bbox,
                self.shape,
                self._path,
                self.chunk,
                protocol="none",  # self.protocol
            )
        )