Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always specify explicitly that methods do not change an object in place but return a new one #189

Closed
lars-reimann opened this issue Apr 14, 2023 · 3 comments · Fixed by #279
Assignees
Labels
documentation 📖 Improvements or additions to documentation good first issue Good for newcomers released Included in a release

Comments

@lars-reimann
Copy link
Member

lars-reimann commented Apr 14, 2023

Users that are coming from other libraries like scikit-learn could easily forget that methods like fit do not work in place but return a new, fitted model/transformer.

We should always highlight this in the docstrings of these methods. This includes

  • fit methods of TableTransformers
  • fit methods of Classifiers
  • fit methods of Regressors
  • methods of Table that return a Table.

See https://stdlib.safe-ds.com/en/latest/development/guidelines/#document-api-elements for the required docstring format.

@lars-reimann lars-reimann added the documentation 📖 Improvements or additions to documentation label Apr 14, 2023
@github-project-automation github-project-automation bot moved this to Backlog in Library Apr 14, 2023
@lars-reimann lars-reimann added the good first issue Good for newcomers label Apr 22, 2023
@alex-senger alex-senger moved this from Backlog to Todo in Library Apr 28, 2023
@zzril
Copy link
Contributor

zzril commented May 5, 2023

Some of the methods of Table that return a Table do actually modify the original table in-place. E.g. remove_columns(), which internally uses Pandas' drop method.
Is this intentional? If so, this issue needs further clarification on which methods' documentation needs to be updated.
If not, these methods need to be changed in order to actually return copies.

@lars-reimann
Copy link
Member Author

lars-reimann commented May 5, 2023

As discussed, the pandas methods don't change data frames in place unless the inplace parameter is set to True. If data is really changed in place, that is not intended.

@PhilipGutberlet PhilipGutberlet self-assigned this May 5, 2023
@PhilipGutberlet PhilipGutberlet moved this from Todo to In Progress in Library May 5, 2023
@PhilipGutberlet PhilipGutberlet moved this from In Progress to Ready for Review in Library May 5, 2023
@lars-reimann lars-reimann moved this from Ready for Review to Todo in Library May 5, 2023
lars-reimann added a commit that referenced this issue May 6, 2023
#279)

Closes #189.

### Summary of Changes

Highlighting the fact, that fitting methods of Classifier, Regressor,
Tabletransformer and certain methods of the _table class do not work in
place.

---------

Co-authored-by: Lars Reimann <[email protected]>
Co-authored-by: megalinter-bot <[email protected]>
@github-project-automation github-project-automation bot moved this from Todo to ✔️ Done in Library May 6, 2023
@lars-reimann
Copy link
Member Author

🎉 This issue has been resolved in version 0.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📖 Improvements or additions to documentation good first issue Good for newcomers released Included in a release
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants