Skip to content

Commit

Permalink
fix+test: use uint16 for small dimensions for 2d
Browse files Browse the repository at this point in the history
  • Loading branch information
William Silversmith committed Jun 22, 2024
1 parent 653d53a commit 55b7398
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions automated_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,24 @@ def test_statistics_big(order):
assert stats["voxel_counts"][1] == 100
assert stats["voxel_counts"][2] == 10 * 10 * 1

# test 2d

labels = np.zeros((50,66000), dtype=np.uint8, order=order)
labels[10:20,10:20] = 1
labels[40:50,40:50] = 2

stats = cc3d.statistics(labels)
assert stats["voxel_counts"][1] == 100
assert stats["voxel_counts"][2] == 10 * 10

labels = np.zeros((66000,60), dtype=np.uint8, order=order)
labels[10:20,10:20] = 1
labels[40:50,40:50] = 2

stats = cc3d.statistics(labels)
assert stats["voxel_counts"][1] == 100
assert stats["voxel_counts"][2] == 10 * 10

@pytest.mark.parametrize("connectivity", (8, 18, 26))
@pytest.mark.parametrize("dtype", TEST_TYPES)
@pytest.mark.parametrize("order", ("C", "F"))
Expand Down
4 changes: 2 additions & 2 deletions cc3d.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,8 @@ def statistics(
return _statistics_helper3d(out_labels, no_slice_conversion, bounding_boxes32, N)
else:
if out_labels.ndim == 2:
bounding_boxes32 = np.zeros(4 * (N + 1), dtype=np.uint32)
return _statistics_helper2d(out_labels, no_slice_conversion, bounding_boxes32, N)
bounding_boxes16 = np.zeros(4 * (N + 1), dtype=np.uint16)
return _statistics_helper2d(out_labels, no_slice_conversion, bounding_boxes16, N)
else:
bounding_boxes16 = np.zeros(6 * (N + 1), dtype=np.uint16)
return _statistics_helper3d(out_labels, no_slice_conversion, bounding_boxes16, N)
Expand Down

0 comments on commit 55b7398

Please sign in to comment.