Readability refactor: kill the error-conversion boilerplate and wrapped chains#8
Merged
Conversation
Readability only; no behavior change (the full suite, stress sweeps, and benchmarks are identical). - impl From<TriangulationError> for PyErr replaces the inherent into_pyerr method, so the 31 call sites that wrapped every core call in .map_err(TriangulationError::into_pyerr) now just use ?; most of the awkward multi-line method chains in the bindings collapse back to single lines - given() collapses the repeated three-arm 'absent argument or explicit Python None' matches to one helper - the eight SimplicesProxy set operators delegate through a shared set_op/set_rop pair instead of repeating the snapshot dance
Readability only; no behavior change. - coord_2d/coord_3d replace the robust::Coord construction closures that were redefined inline in every predicate - sign() replaces the repeated three-way if/else blocks - validate_simplex() dedupes the 'dim + 1 points of equal dimension' check that circumsphere, volume, precise_volume, and robust_in_circumsphere each spelled out
Readability only; no behavior change.
- TriangulationError::value() collapses the three-line
Err(TriangulationError::Value("...".to_string())) returns
- containing() uses plain loops instead of nested map/filter/collect
chains wrapped across a dozen lines
- facet_neighbour() names the 'other simplex across this facet'
lookup shared by the walk and opposing_vertices
- detach_vertex() dedupes the failed-insertion rollback that
extend_hull and add_point both spelled out
- summed_volume uses a for loop instead of a try_fold with a
turbofish
This was referenced Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pure readability pass, net −108 lines (251+/359−) with zero behavior change. Three thematic commits:
PyO3 layer —
impl From<TriangulationError> for PyErrreplaces the inherentinto_pyerr, so the 31 call sites that wrapped every core call in.map_err(TriangulationError::into_pyerr)now just use?. This was the single biggest source of awkward rustfmt line splits; most bindings collapse back to one line per call. Also: agiven()helper for the repeated "absent argument or explicit PythonNone" three-arm matches, and the eightSimplicesProxyset operators delegate through one sharedset_op/set_roppair.Geometry —
coord_2d/coord_3dreplace therobust::Coordclosures redefined inline in every predicate,sign()replaces the repeated three-way if/else blocks, andvalidate_simplex()dedupes the "dim+1 points of equal dimension" check spelled out in four functions.Core —
TriangulationError::value()collapses the three-line error returns,containing()uses plain loops instead of dozen-line map/filter chains,facet_neighbour()names the "other simplex across this facet" lookup shared by the walk andopposing_vertices,detach_vertex()dedupes the failed-insertion rollback duplicated betweenextend_hullandadd_point, andsummed_volumetrades a turbofishtry_foldfor a for loop.Verification (identical to main on every axis)
pytest: 112 passed;cargo test --lib --tests: 18 passed