Skip to content

Barrier cell-splitting has no test coverage #16

Description

@rhugman

VoronoiTessellator._enforce_barriers splits Voronoi cells crossed by barrier lines — the feature the README describes as "enforce barrier features by cutting through cells". It selects which lines to cut with:

barriers_to_cut = self.cm.clean_lines[mask_barrier & mask_no_straddle & mask_no_quad_buffer]

That is: is_barrier=True and no straddle_width and no quad_buffer. Straddled and quad-buffered barriers are already aligned by the mesher, so they are correctly excluded.

Every is_barrier=True in the test suite is paired with quad_buffer=True:

tests/test_buffer.py:25    is_barrier=True,  ->  quad_buffer=True
tests/test_buffer.py:119   is_barrier=True,  ->  quad_buffer=True
tests/test_buffer.py:151   is_barrier=True,  ->  quad_buffer=True
tests/test_buffer.py:159   is_barrier=True,  ->  quad_buffer=True
tests/test_buffer.py:196   is_barrier=True,  ->  quad_buffer=True
tests/test_buffer.py:290   is_barrier=True,  ->  quad_buffer=True
tests/test_buffer.py:327   is_barrier=True,  ->  quad_buffer=True

All seven are filtered out by mask_no_quad_buffer, so the cell-splitting body never executes in the test suite — not the shapely.ops.split call, not the largest-piece-keeps-the-id rule, not the new-id allocation, not the except path.

The path does work; a manual run with is_barrier=True and no quad_buffer cuts cells as expected. It is simply unguarded against regression.

Why it matters now

The companion issue about max_id += 1 and uint64 promotion is a suspected NumPy 1.x bug living entirely inside this untested body. The minimum-dependencies CI job pins numpy==1.24.0 and would be the natural place to catch it — but it cannot, because nothing reaches the code.

Suggested test

def test_plain_barrier_splits_cells():
    cm = ConceptualMesh(crs="EPSG:3857")
    cm.add_polygon(Polygon([(0,0),(20,0),(20,20),(0,20)]), zone_id=1, resolution=4.0)
    cm.add_line(LineString([(2,10),(18,10)]), line_id="fault",
                resolution=2.0, is_barrier=True)   # no quad_buffer, no straddle_width
    ...

Assert that no cell geometry crosses the barrier, that ids stay unique, that node_id keeps an integer dtype, and that total area is conserved.

Pre-existing gap on develop — raised separately from #12, which adds 204 tests but does not cover this path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions