Skip to content

[Sad Catapella B6][Numeric correctness] Micrometre conversion overflow can classify radically different pixel sizes as equal #93

Closed

Description

@guijacquemet

Scope and classification

Sad Catapella Batch 6; pinned d7a538e56d41ac1093ba79adcad397c21b3dfd32. Confirmed source-level floating-point defect for finite, positive metadata values that overflow during unit conversion; no test executed.

Evidence

Analytic counterexample

One image has a metadata X/Y pixel size 1e308 meter (finite, positive), another has 0.5 micrometer. The first conversion multiplies by 1e6 and produces +inf. Under the current comparison abs(0.5 - inf) <= 1e-3 * max(0.5, inf), both sides become inf, so the comparison incorrectly evaluates True. Thus _check_pixel_sizes can suppress different_pixel_sizes even with obviously incomparable sizes. The public same_pixel_size(PhysicalSizes(...)) instead raises on nonfinite converted values, leading to inconsistent behavior between API and preflight.

Fix / tests

Always validate finiteness after unit conversion. Define whether conversion overflow makes a size unknown with an explicit warning, or is a named invalid calibration, but never emit inf as a physical length. Fix both PhysicalSizes.micrometers and to_micrometers; ensure metadata._micrometers and pixel_size_groups cannot pass inf/NaN into comparator. Regression cases: 1e308 meter, near overflow boundaries, picometers at tiny scales, known unit cross-conversion, invalid/infinite metadata and valid physically reasonable values. No Numba; simple scalar validation.

Activity

  1. added a commit that references this issue on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions