Skip to content

Add IndirectTransform with tests (clean PR)#31379

Closed
roshandhiman wants to merge 0 commit intomatplotlib:mainfrom
roshandhiman:indirect-transform-clean
Closed

Add IndirectTransform with tests (clean PR)#31379
roshandhiman wants to merge 0 commit intomatplotlib:mainfrom
roshandhiman:indirect-transform-clean

Conversation

@roshandhiman
Copy link

PR summary

This PR introduces a new IndirectTransform class that allows applying forward and inverse transformations using user-defined functions.

Why is this change necessary?

Currently, there is no simple utility in matplotlib.transforms to represent transformations defined purely by callable functions. This addition provides a lightweight and flexible abstraction for such use cases.

What problem does it solve?

It enables users to define transformations without needing to subclass existing transform classes, making it easier to experiment with custom transformation logic.

What is the reasoning for this implementation?

The implementation keeps the interface minimal by accepting forward and inverse callables and integrating with the existing transform API.


Changes made

  • Added IndirectTransform implementation in lib/matplotlib/transforms.py
  • Added unit tests in lib/matplotlib/tests/test_transforms.py
  • Removed unintended CI/config changes
  • Cleaned merge conflicts and commit history

Minimal example

from matplotlib.transforms import IndirectTransform
import numpy as np

f = lambda x: x + 1
inv = lambda x: x - 1

t = IndirectTransform(f, inv)

data = np.array([1, 2, 3])
print(t.transform(data))  # [2, 3, 4]
---

## Checklist

- [x] Tests added
- [x] CI changes removed
- [x] Clean commit history
- [x] No merge conflicts

---

## AI Disclosure

This PR was created with assistance for guidance and debugging, but all code and decisions were verified manually.

@da-woods
Copy link

(clean PR)

You might want to check the "files changed" list on GitHub...

@anntzer anntzer added the status: autoclose candidate PRs that are not yet ready for review and may be automatically closed in two weeks label Mar 25, 2026
@github-actions
Copy link

⏰ This pull request might be automatically closed in two weeks from now.

Thank you for your contribution to Matplotlib and for the effort you have put into this PR. This pull request does not yet meet the quality and clarity standards needed for an effective review. Project maintainers have limited time for code reviews, and our goal is to prioritize well-prepared contributions to keep Matplotlib maintainable.

Matplotlib maintainers cannot provide one-to-one guidance on this PR. However, if you ask focused, well-researched questions, a community member may be willing to help. 💬

To increase the chance of a productive review:

As the author, you are responsible for driving this PR, which entails doing necessary background research as well as presenting its context and your thought process. If you are a new contributor, or do not know how to fulfill these requirements, we recommend that you familiarize yourself with Matplotlib's development conventions or engage with the community via our Discourse or one of our meetings before submitting code.

If you substantially improve this PR within two weeks, leave a comment and a team member may remove the status: autoclose candidate label and the PR stays open. Cosmetic changes or incomplete fixes will not be sufficient. Maintainers will assess improvements on their own schedule. Please do not ping (@) maintainers.

@melissawm
Copy link
Member

Please undo all the formatting changes that were applied to files you are not touching in this specific PR. Thanks

@roshandhiman roshandhiman force-pushed the indirect-transform-clean branch from d160de6 to de9f36b Compare March 25, 2026 17:36
@roshandhiman roshandhiman force-pushed the indirect-transform-clean branch from de9f36b to e57fe4c Compare March 26, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment