Skip to content

Commit

Permalink
If clearing_bbox is given, disallow annotations not entirely within b…
Browse files Browse the repository at this point in the history
…ounds.
  • Loading branch information
JoeStrout committed Jan 29, 2025
1 parent c951ae6 commit 5b7f81f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions zetta_utils/db_annotations/precomp_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def write_annotations(
annotation_resolution: Optional[Vec3D] = None,
all_levels: bool = True,
clearing_bbox: Optional[BBox3D] = None,
):
): # pylint: disable=too-many-branches
"""
Write a set of line annotations to the file, adding to any already there.
Expand All @@ -562,7 +562,8 @@ def write_annotations(
if not specified, assumes native coordinates (i.e. self.index.resolution)
:param all_levels: if true, write to all spatial levels (chunk sizes).
If false, write only to the lowest level (smallest chunks).
:param clearing_bbox: if given, clear any existing data within these bounds.
:param clearing_bbox: if given, clear any existing data within these bounds;
annotations must be entirely within these bounds.
"""
if not annotations:
logger.info("write_annotations called with 0 annotations to write")
Expand All @@ -583,6 +584,8 @@ def write_annotations(
round(clearing_bbox.end / self.index.resolution),
self.index.resolution,
)
if not all(map(lambda x: x.in_bounds(clearing_idx, strict=True), annotations)):
raise ValueError("All annotations must be strictly within clearing_bbox")

for level in levels:
limit = 0
Expand Down

0 comments on commit 5b7f81f

Please sign in to comment.