pymc icon indicating copy to clipboard operation
pymc copied to clipboard

Add transform_labels to Transform, Simplex, SumTo1, and ZeroSum #7907

Open Mr-Imperium opened this issue 2 weeks ago • 0 comments

Implemented transform_labels method to handle coordinate transformations.

  • Base Transform: Identity (returns labels unchanged).
  • SimplexTransform: Drops the last label.
  • SumTo1: Drops the last label.
  • ZeroSumTransform: Implemented logic to drop labels corresponding to zerosum_axes.

Verified via existing test suite and manual verification script.

Description

This PR addresses Issue #7907 by adding a transform_labels method to the base Transform class and overriding it in specific subclasses. This ensures that when transformations (like Simplex) reduce the dimensionality of the data, the associated coordinates/labels are adjusted accordingly.

Changes implemented:

  • Base Transform: Added transform_labels which returns labels unchanged (identity).
  • SimplexTransform: Overridden to return labels[:-1] (dropping the last label).
  • SumTo1: Overridden to return labels[:-1].
  • ZeroSumTransform: Overridden to handle zerosum_axes, ensuring the last label is dropped for the specific axes being transformed.

Related Issue

  • [x] Closes #7907
  • [ ] Related to #

Checklist

Type of change

  • [x] New feature / enhancement
  • [x] Bug fix
  • [ ] Documentation
  • [ ] Maintenance
  • [ ] Other (please specify):

Mr-Imperium avatar Nov 25 '25 16:11 Mr-Imperium