Skip to content

Fix multi-metric output mislabeling in glcm_texture (#1106)#1107

Merged
brendancol merged 1 commit into
masterfrom
issue-1106
Mar 31, 2026
Merged

Fix multi-metric output mislabeling in glcm_texture (#1106)#1107
brendancol merged 1 commit into
masterfrom
issue-1106

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

Fixes #1106. When glcm_texture() received metrics in any order other than the internal VALID_METRICS order, the output coordinate labels didn't match the actual data. For example, glcm_texture(agg, metric=['homogeneity', 'contrast']) would return a DataArray where result.sel(metric='contrast') actually contained homogeneity values. Silent data corruption.

The kernel always writes output slots in VALID_METRICS order (contrast first, entropy last). The fix sorts the user's metric list into this same order before building coordinate labels.

Test plan

  • 10 new tests covering: sorted helper, reversed order matching solo, arbitrary permutations, all-metrics reversed, standard order regression, angle=None with reversed, dask with reversed
  • All 29 existing GLCM tests still pass

The kernel always writes output slots in VALID_METRICS order, but
coordinate labels were set from the user's list. When metrics were
requested in non-standard order (e.g. ['entropy', 'contrast']),
result.sel(metric='contrast') returned entropy values.

Added _sorted_metrics() to reorder the user's list to match the
kernel's output order. 10 new tests covering various orderings.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Mar 31, 2026
@brendancol brendancol merged commit ccfa6bd into master Mar 31, 2026
11 checks passed
@brendancol brendancol deleted the issue-1106 branch May 4, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

glcm_texture: multi-metric output mislabeled when requested in non-standard order

1 participant