Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 64760f2

Browse filesBrowse files
committed
Import gzip and bz2 only if necessary.
1 parent 235ee25 commit 64760f2
Copy full SHA for 64760f2

File tree

Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed

‎sklearn/datasets/svmlight_format.py

Copy file name to clipboardExpand all lines: sklearn/datasets/svmlight_format.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
# Olivier Grisel <olivier.grisel@ensta.org>
1616
# License: BSD 3 clause
1717

18-
from bz2 import BZ2File
1918
from contextlib import closing
20-
import gzip
2119
import io
2220
import os.path
2321

@@ -122,8 +120,10 @@ def _gen_open(f):
122120

123121
_, ext = os.path.splitext(f)
124122
if ext == ".gz":
123+
import gzip
125124
return gzip.open(f, "rb")
126125
elif ext == ".bz2":
126+
from bz2 import BZ2File
127127
return BZ2File(f, "rb")
128128
else:
129129
return open(f, "rb")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.