Skip to content

Keep persistence-image grids at their requested pixel size - #113

Open
antonsoo wants to merge 3 commits into
scikit-tda:masterfrom
antonsoo:fix/persistence-image-grid
Open

antonsoo wants to merge 3 commits into
scikit-tda:masterfrom
antonsoo:fix/persistence-image-grid

Conversation

@antonsoo

@antonsoo antonsoo commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

PersistenceImager(birth_range=(0, 4.3), pers_range=(0, 4.3), pixel_size=0.1) currently creates a 42-by-42 grid with spacing about 0.1023. Constructor truncation and conversion of rounded widths back to integer counts lose pixels; parameter setters can produce similar errors or expand an unchanged grid.

Compute integer counts first, derive the covered widths from them, and apply the existing centered padding to constructor ranges too. Preserve the other axis when updating one range, and keep the mesh unchanged when reassigning an unchanged parameter. Handle quotient roundoff without adding a pixel to exact multiples, including both 3 * 0.1 and literal 0.9 / 0.3.

Validation: 13 of 31 new constructor/setter/rounding cases fail before; all 31 pass after. The complete suite on current master passes 155 tests, with the existing 19 warnings. Ruff format/lint, wheel/sdist builds and metadata checks pass.

On 360 persistence-image outputs from recorded handwritten-digit diagrams, this corrects 120 shapes and all 84 spacing errors. Every corrected image agrees with an independent Gaussian rectangle-CDF reference (maximum absolute pixel error 1.8e-16). Of the 240 previously correct shapes, 228 outputs stay byte-identical; the other 12 change only last-bit pixel values.

@antonsoo
antonsoo force-pushed the fix/persistence-image-grid branch from 3163c55 to bd476de Compare October 18, 2026 12:36
@codecov

codecov Bot commented Oct 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.47%. Comparing base (00144a8) to head (bd476de).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #113      +/-   ##
==========================================
+ Coverage   79.28%   79.47%   +0.19%     
==========================================
  Files          20       20              
  Lines        1477     1491      +14     
  Branches      271      275       +4     
==========================================
+ Hits         1171     1185      +14     
  Misses        229      229              
  Partials       77       77              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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