|
8 | 8 | # License: BSD 3 clause |
9 | 9 | import os |
10 | 10 | import csv |
11 | | -import sys |
12 | 11 | import shutil |
13 | 12 | import warnings |
14 | 13 | from collections import namedtuple |
@@ -847,30 +846,18 @@ def load_sample_image(image_name): |
847 | 846 |
|
848 | 847 |
|
849 | 848 | def _pkl_filepath(*args, **kwargs): |
850 | | - """Ensure different filenames for Python 2 and Python 3 pickles |
| 849 | + """Return filename for Python 3 pickles |
851 | 850 |
|
852 | | - An object pickled under Python 3 cannot be loaded under Python 2. An object |
853 | | - pickled under Python 2 can sometimes not be loaded correctly under Python 3 |
854 | | - because some Python 2 strings are decoded as Python 3 strings which can be |
855 | | - problematic for objects that use Python 2 strings as byte buffers for |
856 | | - numerical data instead of "real" strings. |
| 851 | + args[-1] is expected to be the ".pkl" filename. For compatibility with |
| 852 | + older scikit-learn versions, a suffix is inserted before the extension. |
857 | 853 |
|
858 | | - Therefore, dataset loaders in scikit-learn use different files for pickles |
859 | | - manages by Python 2 and Python 3 in the same SCIKIT_LEARN_DATA folder so as |
860 | | - to avoid conflicts. |
861 | | -
|
862 | | - args[-1] is expected to be the ".pkl" filename. Under Python 3, a suffix is |
863 | | - inserted before the extension to s |
864 | | -
|
865 | | - _pkl_filepath('/path/to/folder', 'filename.pkl') returns: |
866 | | - - /path/to/folder/filename.pkl under Python 2 |
867 | | - - /path/to/folder/filename_py3.pkl under Python 3+ |
| 854 | + _pkl_filepath('/path/to/folder', 'filename.pkl') returns |
| 855 | + '/path/to/folder/filename_py3.pkl' |
868 | 856 |
|
869 | 857 | """ |
870 | 858 | py3_suffix = kwargs.get("py3_suffix", "_py3") |
871 | 859 | basename, ext = splitext(args[-1]) |
872 | | - if sys.version_info[0] >= 3: |
873 | | - basename += py3_suffix |
| 860 | + basename += py3_suffix |
874 | 861 | new_args = args[:-1] + (basename + ext,) |
875 | 862 | return join(*new_args) |
876 | 863 |
|
|
0 commit comments