Skip to content

Commit 9c3e66e

Browse files
committed
FIX: Delete temporary cache directory
The cluster/plot_feature_agglomeration_vs_univariate_selection.py example was leaving temporary files in the current directory. The examples/cluster/joblib/ directory remained after running the example. This commit moves the cache to a temporary folder.
1 parent f9c5458 commit 9c3e66e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/cluster/plot_feature_agglomeration_vs_univariate_selection.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
print __doc__
2020

21+
import shutil
22+
import tempfile
23+
2124
import numpy as np
2225
import pylab as pl
2326
from scipy import linalg, ndimage
@@ -59,7 +62,8 @@
5962
# Compute the coefs of a Bayesian Ridge with GridSearch
6063
cv = KFold(len(y), 2) # cross-validation generator for model selection
6164
ridge = BayesianRidge()
62-
mem = Memory(cachedir='.', verbose=1)
65+
cachedir = tempfile.mkdtemp()
66+
mem = Memory(cachedir=cachedir, verbose=1)
6367

6468
# Ward agglomeration followed by BayesianRidge
6569
A = grid_to_graph(n_x=size, n_y=size)
@@ -99,3 +103,6 @@
99103
pl.title("Feature Agglomeration")
100104
pl.subplots_adjust(0.04, 0.0, 0.98, 0.94, 0.16, 0.26)
101105
pl.show()
106+
107+
# Attempt to remove the temporary cachedir, but don't worry if it fails
108+
shutil.rmtree(cachedir, ignore_errors=True)

0 commit comments

Comments
 (0)