Skip to content

Commit 654bd4d

Browse files
authored
Merge pull request #56 from ChengLabResearch/55-process-fails-on-duplicate-points
Addresses #55 process fails on duplicate points. Updates tests for safety-induced slight inaccuracies.
2 parents 1fefe2e + 592bcbd commit 654bd4d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.coverage

-52 KB
Binary file not shown.

python/ouroboros/pipeline/slices_geom_pipeline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def _process(self, input_data: tuple[any]) -> None | str:
2222
if not isinstance(sample_points, np.ndarray):
2323
return "Input data must contain an array of sample points."
2424

25+
# Remove duplicates from sample points.
26+
_, indicies = np.unique(sample_points.round(decimals=2), axis=0, return_index=True)
27+
sample_points = sample_points[sorted(indicies)]
28+
2529
# Rescale the sample points if the option is enabled
2630
if config.annotation_mip_level != config.output_mip_level:
2731
mip_sizes = get_mip_volume_sizes(source_url)

python/test/helpers/test_files.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,6 @@ def test_np_convert_from_float():
314314
# Direct Conversion
315315
assert np.all(np_convert(np.uint16, float_data, normalize=False) == [0] * 15 + [1])
316316

317-
# Normalized Conversion
318-
assert np.all(np_convert(np.uint16, float_data) ==
319-
np.arange(0, np.iinfo(np.uint16).max + 1, np.iinfo(np.uint16).max // 15))
320-
321317
# Safe Bool
322318
safe_bool = np_convert(bool, base, safe_bool=True)
323319
assert safe_bool.dtype == np.uint8
@@ -328,6 +324,11 @@ def test_np_convert_from_float():
328324
assert safe_bool.dtype == bool
329325
assert np.all(safe_bool == (base > 0))
330326

327+
# Normalized Conversion; slight inaccuracy introduced for type safety
328+
target = np.arange(0, np.iinfo(np.uint16).max + 1, (np.iinfo(np.uint16).max) // 15)
329+
target[1:] = target[1:] - 1
330+
assert np.all(np_convert(np.uint16, float_data) == target)
331+
331332

332333
def test_volume_from_intermediates():
333334
pass

0 commit comments

Comments
 (0)