pymc
pymc copied to clipboard
Add transform_labels to Transform, Simplex, SumTo1, and ZeroSum #7907
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: Addedtransform_labelswhich returns labels unchanged (identity). SimplexTransform: Overridden to returnlabels[:-1](dropping the last label).SumTo1: Overridden to returnlabels[:-1].ZeroSumTransform: Overridden to handlezerosum_axes, ensuring the last label is dropped for the specific axes being transformed.
Related Issue
- [x] Closes #7907
- [ ] Related to #
Checklist
- [x] Checked that the pre-commit linting/style checks pass
- [x] Included tests that prove the fix is effective or that the new feature works
- [x] Added necessary documentation (docstrings and/or example notebooks)
- [ ] If you are a pro: each commit corresponds to a relevant logical change
Type of change
- [x] New feature / enhancement
- [x] Bug fix
- [ ] Documentation
- [ ] Maintenance
- [ ] Other (please specify):