Skip to content

Conversation

@cookpa
Copy link
Member

@cookpa cookpa commented Sep 19, 2025

To save an unnecessary clone, we were lazily cloning the data but if the labels are actually uint32, the variable wasn't properly initialized.

For label_stats, add checks that labels are unsigned. Also re-index data in the returned DF by label - it was previously sorted by label, but the pandas index was not updated, so a merge on index would be wrong

To save an unnecessary clone, we were lazily cloning the data but if the labels are actually uint32, the variable wasn't properly initialized.

For label_stats, add checks that labels are unsigned. Also re-index data in the returned DF by label - it was previously sorted by label, but the pandas index was not updated
@cookpa cookpa requested a review from Copilot September 19, 2025 19:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug related to handling uint32 labels in label geometry measures and improves the label_stats function. The main issue was that when labels were already uint32, a variable wasn't properly initialized, causing potential failures.

  • Fixes variable initialization bug when labels are already uint32 in label_geometry_measures
  • Adds validation checks to ensure labels can be represented as uint32 in both functions
  • Updates label_stats to properly reset DataFrame index after sorting

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/labelStats.cxx Changes vector types from double to LabelType for labelvals and counts arrays
ants/label/label_stats.py Adds uint32 validation checks and fixes DataFrame index after sorting
ants/label/label_geometry_measures.py Fixes uninitialized variable bug when labels are already uint32

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@coveralls
Copy link

Coverage Status

coverage: 76.861% (-0.009%) from 76.87%
when pulling 2506b12 on labelstats
into cdf373f on master.

@cookpa cookpa merged commit 3f962d8 into master Sep 24, 2025
2 checks passed
@cookpa cookpa deleted the labelstats branch September 24, 2025 14:15
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.

3 participants