Skip to content

Commit

Permalink
satisfy flake8 for pointset.py and catch centroids with no points
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmetNSimsek committed Dec 12, 2024
1 parent 97f22b7 commit ba32bcd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion siibra/locations/pointset.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def from_points(points: List["point.Point"], newlabels: List[Union[int, float, t
PointSet
"""
if len(points) == 0:
raise EmptyPointSetError(f"Cannot create a PointSet without any coordinates.")
raise EmptyPointSetError("Cannot create a PointSet without any points.")

spaces = {p.space for p in points}
assert len(spaces) == 1, f"PointSet can only be constructed with points from the same space.\n{spaces}"
coords, sigmas, labels = zip(*((p.coordinate, p.sigma, p.label) for p in points))
Expand Down
5 changes: 4 additions & 1 deletion siibra/volumes/parcellationmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,10 @@ def compute_centroids(self, split_components: bool = True, **fetch_kwargs) -> Di
space=self.space,
split_components=split_components,
)
centroids[regionname] = pointset.from_points([c.centroid for c in props])
try:
centroids[regionname] = pointset.from_points([c.centroid for c in props])
except exceptions.EmptyPointSetError:
centroids[regionname] = None
return centroids

def get_resampled_template(self, **fetch_kwargs) -> _volume.Volume:
Expand Down

0 comments on commit ba32bcd

Please sign in to comment.