Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
robert committed Nov 22, 2024
1 parent dbbf4f6 commit 12e99e8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
11 changes: 11 additions & 0 deletions TPTBox/core/poi_fun/poi_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ def __init__(self, input_poi: poi.POI | POI_Descriptor):
raise NotImplementedError(input_poi)
self._centroids = global_points

def __str__(self) -> str:
return str(self._centroids)

@property
def zoom(self):
return (1, 1, 1)

@property
def origin(self):
return (0, 0, 0)

@property
def is_global(self) -> bool:
"""
Expand Down
9 changes: 8 additions & 1 deletion unit_tests/test_centroids_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ def get_centroids(x: tuple[int, int, int] = (50, 30, 40), num_point=3, default_s
for _ in range(num_point):
point = tuple(random.randint(1, a * 100) / 100.0 for a in x)
out_points[random.randint(1, 256), random.randint(1, 256) if default_sub is None else 50] = point
return POI(out_points, get_random_ax_code(), zoom=(random.random() * 3, random.random() * 3, random.random() * 3), shape=x)
return POI(
out_points,
get_random_ax_code(),
zoom=(random.random() * 3, random.random() * 3, random.random() * 3),
shape=x,
origin=(0, 0, 0),
rotation=np.eye(3),
)


def get_centroids2(x: tuple[int, int, int] = (50, 30, 40), num_point=3):
Expand Down
4 changes: 2 additions & 2 deletions unit_tests/test_poi_autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def test_remove_centroid(self):
poi.centroids = {(5, 51): (1.0, 2.0, 3.0), (25, 12): (4.0, 5.0, 6.0)}

# Remove a centroid using the remove_centroid method
poi.remove_centroid_((5, 51))
poi.remove_((5, 51))

# Check that the centroid has been removed
assert (5, 51) not in poi.centroids, poi
Expand Down Expand Up @@ -449,7 +449,7 @@ def test_remove_nonexistent_centroid(self):
poi.centroids = {(12, 13): (1.0, 2.0, 3.0), (19, 23): (4.0, 5.0, 6.0)}

# Remove a centroid that doesn't exist
poi.remove_centroid((50, 50))
poi.remove_((50, 50))

# Check that the centroids are not modified
assert poi.centroids == {(12, 13): (1.0, 2.0, 3.0), (19, 23): (4.0, 5.0, 6.0)}
Expand Down

0 comments on commit 12e99e8

Please sign in to comment.