Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 381315d

Browse files
committed
Merge pull request scikit-learn#5886 from sieben/with_statement
[MRG+1] Use with to handle file
2 parents 0159bc4 + 845a7a1 commit 381315d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

benchmarks/bench_plot_randomized_svd.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,9 @@
117117
big_sparse_datasets = ['big sparse matrix', 'rcv1']
118118

119119

120-
def unpickle(file):
121-
fo = open(file, 'rb')
122-
dict = pickle.load(fo, encoding='latin1')
123-
fo.close()
124-
return dict['data']
120+
def unpickle(file_name):
121+
with open(file_name, 'rb') as fo:
122+
return pickle.load(fo, encoding='latin1')["data"]
125123

126124

127125
def handle_missing_dataset(file_folder):

0 commit comments

Comments
 (0)