Upcoming return value changes #1465
Replies: 3 comments 5 replies
-
Thanks for letting us know. However returning Removing the return value in |
Beta Was this translation helpful? Give feedback.
-
We've speculated that it may have originally been done this way to follow sklearn conventions, although not many other sklearn conventions were followed. I don't think we really need to do this change, it's just getting rod of an unusual code smell. Right now I don't think the return-self convention benefits the code much - the ability to chain methods isn't something we use in our demos nor is it something that sounds like a good idea (making a one-liner with many method calls seems bad for easy reading of code). For the other methods that return self, nothing in our code looks at the return code, and the refactor is pretty easy. Is there something particularly useful you find in fit() returning self? It's possible I'm overlooking something. |
Beta Was this translation helpful? Give feedback.
-
(I'll also talk with the nemos author and see if he has thoughts) |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am working on some changes across the codebase that will remove the return values from methods that:
A) Modify their object inline, and
B) Return self
In such cases, the return values have little use, only permitting the mild convenience of allowing the chaining of multiple methods together on one line of code, and having the disadvantage of it being unclear whether what they return is a distinct object from the the object used for the call (we also have methods that return a distinct object with data cloned from the current object; this is confusing).
One example of this is the CNMF object, which has methods like fit() and compute_residuals() that return self after doing their work.
I had to modify the demos and some test code, where the calling code often looked like this:
cnm = cnm.fit(images)
After this change, it will need to look like
cnm.fit(images)
with no assignment (which was never necessary anyway).
This is a breaking change; if you have modified notebooks, when you next upgrade Caiman (after what will probably be the next release) you will need to change them (but the changes are thankfully trivial). You could also change them now without changing the function of your code.
Beta Was this translation helpful? Give feedback.
All reactions