Fix unused rate_func parameter with Unwrite#4732
Conversation
|
Keeping the explicit rate_func parameter in init is better. The problem with your way of deleting it from init and making it pass through kwargs, is: But, if you keep it explicit in init and write an argument rate_func = rate_func in super(), then the benefits are: The explicit parameter is essentially documentation that also enforces correctness. **kwargs is a kind of black hole. anything goes in, no validation, no visibility. So, effectively, i would suggest you to not delete it form init, but keep it there, and in super(), write another parameter: rate_func = rate_func. |
This looks like an AI answer, so I'm not sure if answering is of any use :/ . As far as I can see, the function already uses kwargs, many other parameters are currently passed in the same way, numerous other Animation subclasses that can use
Additionally, if your intent in the long run is to add all possible parameters to function signatures to ensure that the "advantages" you enumerated, this would introduce a lot of code redundancy, would likely be error-prone, and be a pain to maintain should new parameters be introduced or existing parameters be changed/removed. |
The top 2 points(except the one about IDE autocomplete and about typo) were my own opinion, but then i asked an AI, in the hope of knowing more about it. But then, the AI suggested about that IDE autocomplete and that typo remark and that seemed valid point too. So, I added them too.
That's my own opinion. Although, if you need/want, you can check the contributing section here: https://docs.manim.community/en/stable/.
Because rate_func is one of the most commonly used parameters when using such animations. A user shouldn't have to dig through Write, then Animation, just to find out they can pass rate_func to Unwrite. Keeping it explicit makes the class immediately usable without that extra research.
Same reason as above.
I use VSCode. In that, it doesn't show, unless the parameter, it's typehint and default value is explicitly declared in init.
Actually, that is relevant. When rate_func is in the signature, a typo like rate_fun = linear would raise a TypeError saying: init got an unexpected keyword argument rate_fun. But if rate_func is removed from the signature, and is passed through kwargs, then that typo passes through without giving any error. The explicit signature acts as a validation layer that passing it through kwargs doesn't provide. And the important question is whether the explicit signature is better, not whether the PR introduced the problem. However, I would wait to see what the other devs have to say. |
Overview
Fix an issue that causes the
rate_funcfunction passed toUnwriteto be ignored.Further Information and Comments
I chose to simply remove the
rate_funcparameter so it is passed down to theWritesuper (with the same default value) instead of repeating the unused parameter in the call to__init__.This appears to be a single-occurence issue, a quick look through other creation classes does not show this error again.
Reviewer Checklist