Skip to content

Handle empty HKLTable edge case in calc_corrections #50

@coderabbitai

Description

@coderabbitai

Problem

In mdx2.command_line.reintegrate, when processing image chunks, it's possible for all pixels in a chunk to be masked out, resulting in an empty HKLTable being passed to calc_corrections.

While the division operations (tab.phi /= tab.pixels, etc.) handle empty arrays correctly, the subsequent call to calc_corrections may encounter issues when operating on empty tables. This behavior has not been thoroughly tested.

Suggested Approach

  1. Refactor calc_corrections: Ensure the function gracefully handles empty HKLTable inputs, either by:

    • Adding explicit checks and early returns for empty tables
    • Ensuring all operations within the function are safe for empty arrays
  2. Add unit tests: Create test cases covering:

    • Empty HKLTable input to calc_corrections
    • Empty table propagation through the reintegration workflow
    • Verification that empty chunks don't cause failures

Context

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions