Skip to content

[MRG] Simplify creation of pickle path #15237

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

Merged
merged 2 commits into from
Oct 21, 2019

Conversation

sbehren
Copy link
Contributor

@sbehren sbehren commented Oct 13, 2019

Reference Issues/PRs

Contributes to #11991

What does this implement/fix? Explain your changes.

The function
sklearn.datasets.base._pkl_filepath
is a compatibility function for Python 2 and Python 3 support.

The function expects path components as *args and constructs and returns the path to a pickel from it.

It modifies the last path component as follows:

For Python 3, it adds a suffix ('_py3' by default, or the value of the kwarg 'py3_suffix' if specified).
For Python 2, it does nothing .
It then concatenates its arguments using os.path.join and returns the
result.

If Python 2 support is to be deprecated, we can simplify the code: Just
always add the suffix. We cannot get rid of the function entirely since
some users still might have Python 2 pickles on their filesystem.

We can also shorten the docstring.

Any other comments?

@rth As explained in the thread of MR #15231 I cannot reopen the latter due to a force push (did not know this and sorry again).

Sönke Behrends added 2 commits October 13, 2019 14:52
The function
sklearn.datasets.base._pkl_filepath
is a compatibility function for Python 2 and Python 3 support.

The function expects path components as *args and constructs and returns the path to a pickel from it.

It modifies the last path component as follows:

For Python 3, it adds a suffix ('_py3' by default, or the value of the kwarg 'py3_suffix' if specified).
For Python 2, it does nothing .
It then concatenates its arguments using os.path.join and returns the
result.

If Python 2 support is to be deprecated, we can simplify the code: Just
always add the suffix. We cannot get rid of the function entirely since
some users still might have Python 2 pickles on their filesystem.

We can also shorten the docstring.
@sbehren sbehren changed the title Simplify creation of pickle path [MRG] Simplify creation of pickle path Oct 13, 2019
@thomasjpfan thomasjpfan merged commit 5c9f090 into scikit-learn:master Oct 21, 2019
@thomasjpfan
Copy link
Member

Thank you @sbehren !

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.

3 participants