Skip to content

Commit 5419878

Browse files
committed
P3K range vs. xrange
1 parent 50dbadb commit 5419878

40 files changed

+52
-28
lines changed

benchmarks/bench_plot_fastkmeans.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def compute_bench_2(chunks):
6262
means = np.array([[1, 1], [-1, -1], [1, -1], [-1, 1],
6363
[0.5, 0.5], [0.75, -0.5], [-1, 0.75], [1, 0]])
6464
X = np.empty((0, 2))
65-
for i in xrange(8):
65+
for i in range(8):
6666
X = np.r_[X, means[i] + 0.8 * np.random.randn(n_features, 2)]
6767
max_it = len(chunks)
6868
it = 0

benchmarks/bench_plot_nmf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from sklearn.decomposition.nmf import NMF, _initialize_nmf
1313
from sklearn.datasets.samples_generator import make_low_rank_matrix
14+
from sklearn.externals.six.moves import xrange
1415

1516

1617
def alt_nnmf(V, r, max_iter=1000, tol=1e-3, R=None):

benchmarks/bench_random_projections.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import scipy.sparse as sp
2020

2121
from sklearn import clone
22+
from sklearn.externals.six.moves import xrange
2223
from sklearn.random_projection import (SparseRandomProjection,
2324
GaussianRandomProjection,
2425
johnson_lindenstrauss_min_dim)

benchmarks/bench_sample_without_replacement.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import numpy as np
1616
import random
1717

18+
from sklearn.externals.six.moves import xrange
1819
from sklearn.utils.random import sample_without_replacement
1920

2021

examples/applications/svm_gui.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
from sklearn import svm
3737
from sklearn.datasets import dump_svmlight_file
38+
from sklearn.externals.six.moves import xrange
3839

3940
y_min, y_max = -50, 50
4041
x_min, x_max = -50, 50

examples/document_classification_20newsgroups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def predict(self, X):
282282

283283
indices = np.arange(len(results))
284284

285-
results = [[x[i] for x in results] for i in xrange(4)]
285+
results = [[x[i] for x in results] for i in range(4)]
286286

287287
clf_names, score, training_time, test_time = results
288288
training_time = np.array(training_time) / np.max(training_time)

examples/ensemble/plot_adaboost_multiclass.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333

3434
import pylab as pl
3535

36-
from sklearn.ensemble import AdaBoostClassifier
37-
from sklearn.tree import DecisionTreeClassifier
3836
from sklearn.datasets import make_gaussian_quantiles
37+
from sklearn.ensemble import AdaBoostClassifier
38+
from sklearn.externals.six.moves import xrange
3939
from sklearn.metrics import accuracy_score
40+
from sklearn.tree import DecisionTreeClassifier
4041

4142

4243
X, y = make_gaussian_quantiles(n_samples=13000, n_features=10,

examples/ensemble/plot_adaboost_twoclass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
pl.axis("tight")
6363

6464
# Plot the training points
65-
for i, n, c in zip(xrange(2), class_names, plot_colors):
65+
for i, n, c in zip(range(2), class_names, plot_colors):
6666
idx = np.where(y == i)
6767
pl.scatter(X[idx, 0], X[idx, 1],
6868
c=c, cmap=pl.cm.Paired,
@@ -76,7 +76,7 @@
7676
twoclass_output = bdt.decision_function(X)
7777
plot_range = (twoclass_output.min(), twoclass_output.max())
7878
pl.subplot(122)
79-
for i, n, c in zip(xrange(2), class_names, plot_colors):
79+
for i, n, c in zip(range(2), class_names, plot_colors):
8080
pl.hist(twoclass_output[y == i],
8181
bins=10,
8282
range=plot_range,

examples/ensemble/plot_forest_iris.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from sklearn.datasets import load_iris
2424
from sklearn.ensemble import (RandomForestClassifier, ExtraTreesClassifier,
2525
AdaBoostClassifier)
26+
from sklearn.externals.six.moves import xrange
2627
from sklearn.tree import DecisionTreeClassifier
2728

2829
# Parameters

examples/ensemble/plot_forest_multioutput.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
pl.figure(figsize=(2. * n_faces, 2.26 * 2))
4949
pl.suptitle("Face completion with multi-output forests", size=16)
5050

51-
for i in xrange(1, 1 + n_faces):
51+
for i in range(1, 1 + n_faces):
5252
face_id = np.random.randint(X_test.shape[0])
5353

5454
true_face = np.hstack((X_test[face_id], Y_test[face_id]))

0 commit comments

Comments
 (0)