Skip to content

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 7, 2020

  • Suggest tr1 + tr2 instead of composite_transform_factory(tr1, tr2).
  • No need to implement Transform.__radd__ -- we can only add
    transforms so __add__ is enough.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

- Suggest `tr1 + tr2` instead of `composite_transform_factory(tr1, tr2)`.
- No need to implement `Transform.__radd__` -- we can only add
  transforms so `__add__` is enough.
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Just to be sure, this was thought about: We want tr1 + tr2 and not tr1 @ tr2?

Concatenating transforms is a bit matrix multiplication-like. OTOH + is often used as general join operator (strings, lists, ...). Overall, I think @ would be a bit too sophisticated, and + is the plain simple solution to go.

@anntzer may self-merge if you agree.

@dopplershift
Copy link
Contributor

Concatenation is multiplication for affine transforms. But it's completely not for the non-affine case. While the @ is intriguing, I think because it doesn't apply in general we should stick with +. If someone wanted @ as an alternate, I wouldn't protest.

@anntzer
Copy link
Contributor Author

anntzer commented Jan 9, 2020

A problem is that the order of the operands would have to be inverted (A@B typically means "apply B then A" in linear algebra, but that's spelled B+A right now).
In any case tr1 + tr2 is very widely used in the library right now and this PR is not about changing that, it's just about using it even more.

@anntzer anntzer merged commit bdcd9fc into matplotlib:master Jan 9, 2020
@anntzer anntzer deleted the tradd branch January 9, 2020 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants