diff --git a/GPy/core/parameterization/priors.py b/GPy/core/parameterization/priors.py index a4bbecb3..38cb0d19 100644 --- a/GPy/core/parameterization/priors.py +++ b/GPy/core/parameterization/priors.py @@ -414,7 +414,7 @@ class DGPLVM_KFDA(Prior): def compute_cls(self, x): cls = {} # Appending each data point to its proper class - for j in xrange(self.datanum): + for j in range(self.datanum): class_label = self.get_class_label(self.lbl[j]) if class_label not in cls: cls[class_label] = [] @@ -553,7 +553,7 @@ class DGPLVM(Prior): def compute_cls(self, x): cls = {} # Appending each data point to its proper class - for j in xrange(self.datanum): + for j in range(self.datanum): class_label = self.get_class_label(self.lbl[j]) if class_label not in cls: cls[class_label] = [] @@ -572,7 +572,7 @@ class DGPLVM(Prior): # Adding data points as tuple to the dictionary so that we can access indices def compute_indices(self, x): data_idx = {} - for j in xrange(self.datanum): + for j in range(self.datanum): class_label = self.get_class_label(self.lbl[j]) if class_label not in data_idx: data_idx[class_label] = [] @@ -591,7 +591,7 @@ class DGPLVM(Prior): else: lst_idx = [] # Here we put indices of each class in to the list called lst_idx_all - for m in xrange(len(data_idx[i])): + for m in range(len(data_idx[i])): lst_idx.append(data_idx[i][m][0]) lst_idx_all.append(lst_idx) return lst_idx_all @@ -627,7 +627,7 @@ class DGPLVM(Prior): # pdb.set_trace() # Calculating Bi B_i[i] = (M_i[i] - M_0).reshape(1, self.dim) - for k in xrange(self.datanum): + for k in range(self.datanum): for i in data_idx: N_i = float(len(data_idx[i])) if k in lst_idx_all[i]: @@ -772,7 +772,7 @@ class DGPLVM_T(Prior): def compute_cls(self, x): cls = {} # Appending each data point to its proper class - for j in xrange(self.datanum): + for j in range(self.datanum): class_label = self.get_class_label(self.lbl[j]) if class_label not in cls: cls[class_label] = [] @@ -791,7 +791,7 @@ class DGPLVM_T(Prior): # Adding data points as tuple to the dictionary so that we can access indices def compute_indices(self, x): data_idx = {} - for j in xrange(self.datanum): + for j in range(self.datanum): class_label = self.get_class_label(self.lbl[j]) if class_label not in data_idx: data_idx[class_label] = [] @@ -810,7 +810,7 @@ class DGPLVM_T(Prior): else: lst_idx = [] # Here we put indices of each class in to the list called lst_idx_all - for m in xrange(len(data_idx[i])): + for m in range(len(data_idx[i])): lst_idx.append(data_idx[i][m][0]) lst_idx_all.append(lst_idx) return lst_idx_all @@ -846,7 +846,7 @@ class DGPLVM_T(Prior): # pdb.set_trace() # Calculating Bi B_i[i] = (M_i[i] - M_0).reshape(1, self.dim) - for k in xrange(self.datanum): + for k in range(self.datanum): for i in data_idx: N_i = float(len(data_idx[i])) if k in lst_idx_all[i]: diff --git a/GPy/inference/optimization/stochastics.py b/GPy/inference/optimization/stochastics.py index dc71d539..f1532bc5 100644 --- a/GPy/inference/optimization/stochastics.py +++ b/GPy/inference/optimization/stochastics.py @@ -30,7 +30,7 @@ class SparseGPMissing(StochasticStorage): Thus, we can just make sure the loop goes over self.d every time. """ - self.d = xrange(model.Y_normalized.shape[1]) + self.d = range(model.Y_normalized.shape[1]) class SparseGPStochastics(StochasticStorage): """ diff --git a/GPy/kern/_src/add.py b/GPy/kern/_src/add.py index 82c84c52..77f0d76e 100644 --- a/GPy/kern/_src/add.py +++ b/GPy/kern/_src/add.py @@ -165,7 +165,7 @@ class Add(CombinationKernel): else: eff_dL_dpsi1 += dL_dpsi2.sum(0) * p2.psi1(Z, variational_posterior) * 2. grads = p1.gradients_qX_expectations(dL_dpsi0, eff_dL_dpsi1, dL_dpsi2, Z, variational_posterior) - [np.add(target_grads[i],grads[i],target_grads[i]) for i in xrange(len(grads))] + [np.add(target_grads[i],grads[i],target_grads[i]) for i in range(len(grads))] return target_grads def add(self, other): diff --git a/GPy/models/sparse_gp_minibatch.py b/GPy/models/sparse_gp_minibatch.py index d3bbe5fe..10c54d49 100644 --- a/GPy/models/sparse_gp_minibatch.py +++ b/GPy/models/sparse_gp_minibatch.py @@ -82,7 +82,7 @@ class SparseGPMiniBatch(SparseGP): m_f = lambda i: "Precomputing Y for missing data: {: >7.2%}".format(float(i+1)/overall) message = m_f(-1) print(message, end=' ') - for d in xrange(overall): + for d in range(overall): self.Ylist.append(self.Y_normalized[self.ninan[:, d], d][:, None]) print(' '*(len(message)+1) + '\r', end=' ') message = m_f(d) @@ -182,11 +182,11 @@ class SparseGPMiniBatch(SparseGP): full_values[key][value_indices[key]] += current_values[key] """ for key in current_values.keys(): - if value_indices is not None and value_indices.has_key(key): + if value_indices is not None and key in value_indices: index = value_indices[key] else: index = slice(None) - if full_values.has_key(key): + if key in full_values: full_values[key][index] += current_values[key] else: full_values[key] = current_values[key]