Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def generate_cloudpaths(self, slices):
# Slices -> Bbox
slices = Bbox(Vec.zeros(self.shape), self.shape).reify_slices(slices)
requested_bbox = Bbox.from_slices(slices)
# Make sure chunks fit
full_bbox = requested_bbox.expand_to_chunk_size(
self.chunk_shape, 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.key, self.chunk_shape,
protocol=self.protocol
def generate_cloudpaths(self, slices):
# Slices -> Bbox
slices = Bbox(Vec.zeros(self.shape), self.shape).reify_slices(slices)
requested_bbox = Bbox.from_slices(slices)
# Make sure chunks fit
full_bbox = requested_bbox.expand_to_chunk_size(
self.chunk_shape, 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.key, self.chunk_shape,
protocol=self.protocol
))
return cloudpaths, requested_bbox
def generate_chunks(img, offset, chunk_size):
shape = Vec(*img.shape)
offset = Vec(*offset)
bounds = Bbox(offset, shape + offset)
alignment_check = bounds.round_to_chunk_size(
chunk_size, Vec.zeros(*chunk_size))
if not np.all(alignment_check.minpt == bounds.minpt):
raise AlignmentError("""
Only chunk aligned writes are supported by this function.
Got: {}
Volume Offset: {}
Nearest Aligned: {}
""".format(
bounds, Vec.zeros(*chunk_size), alignment_check)
)
bounds = Bbox.clamp(bounds, bounds)
img_offset = bounds.minpt - offset
img_end = Vec.clamp(bounds.size3() + img_offset, Vec.zeros(shape), shape)
def generate_cloudpaths(self, slices):
# Slices -> Bbox
slices = Bbox(Vec.zeros(self.shape), self.shape).reify_slices(slices)
requested_bbox = Bbox.from_slices(slices)
# Make sure chunks fit
full_bbox = requested_bbox.expand_to_chunk_size(
self.chunk_shape, 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.key, self.chunk_shape,
protocol=self.protocol
))
return cloudpaths, requested_bbox
if not np.all(alignment_check.minpt == bounds.minpt):
raise AlignmentError("""
Only chunk aligned writes are supported by this function.
Got: {}
Volume Offset: {}
Nearest Aligned: {}
""".format(
bounds, Vec.zeros(*chunk_size), alignment_check)
)
bounds = Bbox.clamp(bounds, bounds)
img_offset = bounds.minpt - offset
img_end = Vec.clamp(bounds.size3() + img_offset, Vec.zeros(shape), shape)
for startpt in product(*xranges):
startpt = startpt.clone()
endpt = min2(startpt + chunk_size, shape)
spt = (startpt + bounds.minpt).astype(int)
ept = (endpt + bounds.minpt).astype(int)
yield (startpt, endpt, spt, ept)
"""
Shade dest_img at coordinates dest_bbox using the
image contained in src_img at coordinates src_bbox.
The buffer will only be painted in the overlapping
region of the content.
Returns: void
"""
if not Bbox.intersects(dest_bbox, src_bbox):
return
spt = max2(src_bbox.minpt, dest_bbox.minpt)
ept = min2(src_bbox.maxpt, dest_bbox.maxpt)
dbox = Bbox(spt, ept) - dest_bbox.minpt
ZERO = Vec.zeros(dest_bbox.maxpt)
istart = max2(spt - src_bbox.minpt, ZERO)
# FIXME in case some here
#iend = min2(ept - src_bbox.maxpt, ZERO) + src_img.shape
iend = istart + (dest_bbox.maxpt - dest_bbox.minpt)
sbox = Bbox(istart, iend)
dest_img[dbox.to_slices()] = src_img[sbox.to_slices()]