Conversation
|
@mirzaees let me know what you think! |
src/snaphu/_check.py
Outdated
| if isinstance(tile_overlap, int): | ||
| x_overlap = y_overlap = tile_overlap | ||
| elif isinstance(tile_overlap, tuple): | ||
| # cannot unpack, tile_overlap shape is checked later | ||
| x_overlap = tile_overlap[0] | ||
| y_overlap = tile_overlap[1] |
There was a problem hiding this comment.
| if isinstance(tile_overlap, int): | |
| x_overlap = y_overlap = tile_overlap | |
| elif isinstance(tile_overlap, tuple): | |
| # cannot unpack, tile_overlap shape is checked later | |
| x_overlap = tile_overlap[0] | |
| y_overlap = tile_overlap[1] | |
| if isinstance(tile_overlap, int): | |
| y_overlap = x_overlap = tile_overlap | |
| elif isinstance(tile_overlap, tuple): | |
| # cannot unpack, tile_overlap shape is checked later | |
| y_overlap = tile_overlap[0] | |
| x_overlap = tile_overlap[1] |
There was a problem hiding this comment.
(though i'm seeing that elsewhere in the code it a little ambiguous if the tuple is (row, col) or (x, y). i'm the tuple is (row, column) )
There was a problem hiding this comment.
The ntiles docs say row / col, so I may have to revert this: https://github.com/Jaapel/snaphu-py/blob/afe62434dfeddf9875dadf09784c412228f38d5c/src/snaphu/_unwrap.py#L213. Can you confirm?
src/snaphu/_check.py
Outdated
| tile_shapes_max = ( | ||
| arr.shape[0] + 1 // ntiles[0] + x_overlap, | ||
| arr.shape[1] + 1 // ntiles[1] + y_overlap, | ||
| ) |
There was a problem hiding this comment.
was this logic taken from somewhere in snaphu? i dont think it looks right... + 1 // ntiles[0] will always either be 1 or 0, and this would . maybe you want something like
| ) | |
| # in case tile exceeds max array size | |
| tile_height = math.ceil(arr.shape[0] / ntiles[0]) + y_overlap | |
| tile_width = math.ceil(arr.shape[1] / ntiles[1]) + x_overlap | |
| tile_shapes_max = (tile_height, tile_width) | |
but it could be good to check the C code for the actual max shape
There was a problem hiding this comment.
I forget the ( in the answer you've reviewed. I also updated the tests to be more precise.
gmgunter
left a comment
There was a problem hiding this comment.
Thanks for taking the time to improve the codebase. Nice use of mocking in the unit test.
src/snaphu/_check.py
Outdated
| # a single tile is input for snaphu | ||
| for size in arr.shape: | ||
| if size > LARGESHORT: | ||
| msg = f"dataset {name} too large for snaphu, shape: {arr.shape}" |
There was a problem hiding this comment.
Let's add some suggestions here to help users work around this.
| msg = f"dataset {name} too large for snaphu, shape: {arr.shape}" | |
| msg = ( | |
| f"{name} dataset with shape {arr.shape} exceeds max dimensions" | |
| " supported by SNAPHU. Consider using tiling and disabling the" | |
| " regrow_conncomps and single_tile_reoptimize options" | |
| ) |
Co-authored-by: Geoffrey Gunter <12984092+gmgunter@users.noreply.github.com>
Co-authored-by: Geoffrey Gunter <12984092+gmgunter@users.noreply.github.com>
Co-authored-by: Geoffrey Gunter <12984092+gmgunter@users.noreply.github.com>
Co-authored-by: Geoffrey Gunter <12984092+gmgunter@users.noreply.github.com>
Co-authored-by: Geoffrey Gunter <12984092+gmgunter@users.noreply.github.com>
Co-authored-by: Geoffrey Gunter <12984092+gmgunter@users.noreply.github.com>
Co-authored-by: Geoffrey Gunter <12984092+gmgunter@users.noreply.github.com>
Co-authored-by: Geoffrey Gunter <12984092+gmgunter@users.noreply.github.com>
Co-authored-by: Geoffrey Gunter <12984092+gmgunter@users.noreply.github.com>
|
Thanks for the extended review! I implemented all your suggestions @gmgunter . |
|
@scottstanie and @gmgunter please approve this PR if it is final |
Fixes #111 .
Tests use
unittest.mock.MagicMockto avoid creating large arrays during testing.