Skip to content

fix: correct rectangular grid cache cell bounds - #8

Draft
afonsobspinto wants to merge 1 commit into
metacellfrom
feature/fix-rectangular-grid-cell-bounds
Draft

afonsobspinto wants to merge 1 commit into
metacellfrom
feature/fix-rectangular-grid-cell-bounds

Conversation

@afonsobspinto

Copy link
Copy Markdown
Member

Purpose

Draft for internal review before opening against upstream catmaid/CATMAID:dev. The rectangular-cell fix is already included in feature/new-ingestion (PR #7). This PR isolates it for review; it does not introduce a separate ingestion workflow.

What changed and why

update_grid_cell() calculated the lower Y boundary using the cell's width, although its upper Y boundary used the height. This produces the wrong query extent whenever grid cells are rectangular.

  • Before: bottom = h_i * cell_height + cell_width
  • After: bottom = (h_i + 1) * cell_height

The X and Z bounds and square-cell behavior stay the same. The correction applies to normal cache workers and other callers of update_grid_cell(), including the final ingestion cache rebuild.

Before and after examples

For Y index h_i=2, in the same coordinate units as the grid:

Cell width Cell height Before: queried Y range After: queried Y range Effect
10 20 40–50 40–60 Previously omitted the upper half of the cell. A skeleton segment entirely around Y=55 could be missed.
20 10 20–40 20–30 Previously queried beyond the cell, into its neighbor.

The expected range is always [h_i * cell_height, (h_i + 1) * cell_height].

Validation

Adds a regression test that checks the bounding-box parameters passed to the real update_grid_cell() query boundary for zero, positive and negative cell indices. All three subcases fail with the original formula and pass with the correction.

Validated on the internal metacell base with Django 4.2.30, and previously on upstream dev with Django 5.2.17.

python manage.py test catmaid.tests.test_grid_cache

No database migrations. This internal branch contains one fix commit directly on metacell; cherry-pick it onto current upstream dev after internal review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant