Skip to content

[Bug]: Typo in method name: contains_branch_separately #30474

Closed

Description

@brchristian

Bug summary

There is a typo in the method name contains_branch_seperately from lib/matplotlib/transforms.py:

def contains_branch_seperately(self, other_transform):

This should be spelled contains_branch_separately (separate not seperate).

Since this is a public API method, I propose:

  1. Rename the method to contains_branch_separately (correct spelling)
  2. Create an alias from the old contains_branch_seperately spelling to the new method for backwards compatibility
  3. Add a deprecation warning when the old name is used
  4. Update any internal uses and documentation to use the correct spelling

Happy to prepare a PR for this if that makes sense!

Code for reproduction

# Copied from lib/matplotlib/transforms.py

    def contains_branch_seperately(self, other_transform):
        """
        Return whether the given branch is a sub-tree of this transform on
        each separate dimension.

        A common use for this method is to identify if a transform is a blended
        transform containing an Axes' data transform. e.g.::

            x_isdata, y_isdata = trans.contains_branch_seperately(ax.transData)

        """
        if self.output_dims != 2:
            raise ValueError('contains_branch_seperately only supports '
                             'transforms with 2 output dimensions')
        # for a non-blended transform each separate dimension is the same, so
        # just return the appropriate shape.
        return (self.contains_branch(other_transform), ) * 2

Actual outcome

Code runs as expected, but method name contains a typo.

Expected outcome

Method name should be correctly spelled as contains_branch_separately

Additional information

No response

Operating system

No response

Matplotlib Version

Current main branch, as of a3fcf0b (25 August 2025)

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

None

Activity

  1. tacaswell commented on Aug 26, 2025

    @tacaswell
    Member

    It has been misspelled for 13 years (it does not look like this is a US vs UK difference) without notice so I'm not sure of the practical cost of leaving it as-is.

    Did you find this because you spelled it correctly and get a name error or via a tool that searches for misspellings in function names?

    My current thinking is that this is technically wrong, but mostly harmless (function names are full of nonsense words and tab-complete hides a lot of sins) where as if we go through deprecation cycle there is a chance we will break someone due to a completely non-functional API change.

    The most I would want to do is correct the spelling, add the the misspelling as a copy, fix internal usage, and only document the correct spelling in the docs, but leave the misspelling there without warning forever.

  2. brchristian commented on Aug 26, 2025

    @brchristian
    ContributorAuthor

    I found it after having PR #30286 merged, which corrected a whitespace error, so it got me hunting for other misspellings and things of that nature.

    I agree that it’s not the highest priority thing in the world and also appreciate the friction that deprecations introduce. Your proposed approach sounds very reasonable:

    1. Use contains_branch_separately (correct spelling) as the primary method
    2. Keep contains_branch_seperately as a permanent alias without deprecation warning
    3. Update internal usage to the correct spelling
    4. Document only the correct spelling

    Something like this?

    -    def contains_branch_seperately(self, other_transform):
    +    def contains_branch_separately(self, other_transform):
            """
            Return whether the given branch is a sub-tree of this transform on
            each separate dimension.
    
            A common use for this method is to identify if a transform is a blended
            transform containing an Axes' data transform. e.g.::
    
    -            x_isdata, y_isdata = trans.contains_branch_seperately(ax.transData)
    +            x_isdata, y_isdata = trans.contains_branch_separately(ax.transData)
    
            """
            if self.output_dims != 2:
    -            raise ValueError('contains_branch_seperately only supports '
    +            raise ValueError('contains_branch_separately only supports '
                                 'transforms with 2 output dimensions')
            # for a non-blended transform each separate dimension is the same, so
            # just return the appropriate shape.
            return (self.contains_branch(other_transform), ) * 2
    +
    +# Permanent alias for backwards compatibility (historical typo)
    +contains_branch_seperately = contains_branch_separately

    (Plus relevant documentation fixes.)

    Happy to prepare a PR if this sounds reasonable to you.

  3. tacaswell commented on Aug 26, 2025

    @tacaswell
    Member

    Yes, I would review and merge a PR that did that.

  4. added 3 commits that reference this issue on Aug 26, 2025
    5b776f0
    018449d
    8bcdd03
  5. brchristian commented on Aug 26, 2025

    @brchristian
    ContributorAuthor

    I've prepared a PR for your review here: #30475.

  6. added 4 commits that reference this issue on Aug 26, 2025
    f9f77af
    ce9ba96
    7b37286
    93c4bc3
  7. changed the title [-][Bug]: Typo in method name: contains_branch_seperately[/-] [+][Bug]: Typo in method name: contains_branch_separately[/+] on Aug 28, 2025
  8. added 2 commits that reference this issue on Aug 29, 2025
    b478bb6
    a6267f7
  9. added this to the v3.11.0 milestone on Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions