Skip to content

Rename method named "replace" in Mobject and OpenGLMobject#4657

Open
GoThrones wants to merge 2 commits intoManimCommunity:mainfrom
GoThrones:rename-replace-method
Open

Rename method named "replace" in Mobject and OpenGLMobject#4657
GoThrones wants to merge 2 commits intoManimCommunity:mainfrom
GoThrones:rename-replace-method

Conversation

@GoThrones
Copy link
Copy Markdown
Contributor

@GoThrones GoThrones commented Mar 26, 2026

Overview: What does this pull request change?

This PR renames the method named "replace" in mobject.py and opengl_mobject.py, and adds a wrapper with a warning that this method will be deprecated in future.

Motivation and Explanation: Why and how do your changes improve the library?

There are 3 methods named replace in manimce source code.
The one in Scene class does what a method named "replace" is expected to do: it replaces the target mobject with the one calling this method.
The 2nd works with strings.
The third one is in mobject.py and in opengl_mobject.py and it works on mobjects only. The method has been renamed to "match_size_and_position_to" because that's what it does. It matches the size and position of the mobject calling it, to the target mobject. The erstwhile name "replace" in mobject.py and opengl_mobject.py is misleading.

Other places in manimce source code, where this replace method of mobject.py and opengl_mobject.py is called, has been kept as it was, for the time being.

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

@behackl
Copy link
Copy Markdown
Member

behackl commented Mar 26, 2026

This is a deprecation and name change that I do support, replace really does mean something completely different, semantically. I'd like to hear what the other devs think about this as well.

Thanks for your contribution(s)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants