diff --git a/GPy/core/sparse_gp_mpi.py b/GPy/core/sparse_gp_mpi.py index d747ac83..3c3d5398 100644 --- a/GPy/core/sparse_gp_mpi.py +++ b/GPy/core/sparse_gp_mpi.py @@ -38,7 +38,7 @@ class SparseGP_MPI(SparseGP): mean_function=None, inference_method=None, name='sparse gp', Y_metadata=None, mpi_comm=None, normalizer=False): self._IN_OPTIMIZATION_ = False - if mpi_comm != None: + if mpi_comm is not None: if inference_method is None: inference_method = VarDTC_minibatch(mpi_comm=mpi_comm) else: @@ -52,7 +52,7 @@ class SparseGP_MPI(SparseGP): self.mpi_comm = mpi_comm # Manage the data (Y) division - if mpi_comm != None: + if mpi_comm is not None: from ..util.parallel import divide_data N_start, N_end, N_list = divide_data(Y.shape[0], mpi_comm.rank, mpi_comm.size) self.N_range = (N_start, N_end) @@ -65,7 +65,7 @@ class SparseGP_MPI(SparseGP): def __getstate__(self): dc = super(SparseGP_MPI, self).__getstate__() dc['mpi_comm'] = None - if self.mpi_comm != None: + if self.mpi_comm is not None: del dc['N_range'] del dc['N_list'] del dc['Y_local'] @@ -81,7 +81,7 @@ class SparseGP_MPI(SparseGP): @SparseGP.optimizer_array.setter def optimizer_array(self, p): - if self.mpi_comm != None: + if self.mpi_comm is not None: if self._IN_OPTIMIZATION_ and self.mpi_comm.rank==0: self.mpi_comm.Bcast(np.int32(1),root=0) self.mpi_comm.Bcast(p, root=0) diff --git a/GPy/inference/latent_function_inference/var_dtc_parallel.py b/GPy/inference/latent_function_inference/var_dtc_parallel.py index 603623a7..63624ca9 100644 --- a/GPy/inference/latent_function_inference/var_dtc_parallel.py +++ b/GPy/inference/latent_function_inference/var_dtc_parallel.py @@ -118,7 +118,7 @@ class VarDTC_minibatch(LatentFunctionInference): if not het_noise: YRY_full = trYYT*beta - if self.mpi_comm != None: + if self.mpi_comm is not None: from mpi4py import MPI psi0_all = np.array(psi0_full) psi1Y_all = psi1Y_full.copy() @@ -142,7 +142,7 @@ class VarDTC_minibatch(LatentFunctionInference): num_data, output_dim = Y.shape input_dim = Z.shape[0] - if self.mpi_comm != None: + if self.mpi_comm is not None: from mpi4py import MPI num_data_all = np.array(num_data,dtype=np.int32) self.mpi_comm.Allreduce([np.int32(num_data), MPI.INT], [num_data_all, MPI.INT]) @@ -384,7 +384,7 @@ def update_gradients(model, mpi_comm=None): dL_dthetaL += grad_dict['dL_dthetaL'] # Gather the gradients from multiple MPI nodes - if mpi_comm != None: + if mpi_comm is not None: from mpi4py import MPI if het_noise: raise "het_noise not implemented!" @@ -407,7 +407,7 @@ def update_gradients(model, mpi_comm=None): # update for the KL divergence model.variational_prior.update_gradients_KL(X) - if mpi_comm != None: + if mpi_comm is not None: from mpi4py import MPI KL_div_all = np.array(KL_div) mpi_comm.Allreduce([np.float64(KL_div), MPI.DOUBLE], [KL_div_all, MPI.DOUBLE]) @@ -467,7 +467,7 @@ def update_gradients_sparsegp(model, mpi_comm=None): dL_dthetaL += grad_dict['dL_dthetaL'] # Gather the gradients from multiple MPI nodes - if mpi_comm != None: + if mpi_comm is not None: from mpi4py import MPI if het_noise: raise "het_noise not implemented!" diff --git a/GPy/models/ss_mrd.py b/GPy/models/ss_mrd.py index c4dbec78..bf06e4e0 100644 --- a/GPy/models/ss_mrd.py +++ b/GPy/models/ss_mrd.py @@ -183,7 +183,7 @@ class SSMRD(Model): @Model.optimizer_array.setter def optimizer_array(self, p): - if self.mpi_comm != None: + if self.mpi_comm is not None: if self._IN_OPTIMIZATION_ and self.mpi_comm.rank == 0: self.mpi_comm.Bcast(np.int32(1), root=0) self.mpi_comm.Bcast(p, root=0) diff --git a/GPy/plotting/matplot_dep/visualize.py b/GPy/plotting/matplot_dep/visualize.py index a6c2f233..85462cde 100644 --- a/GPy/plotting/matplot_dep/visualize.py +++ b/GPy/plotting/matplot_dep/visualize.py @@ -167,7 +167,7 @@ class lvm(matplotlib_show): def show_sensitivities(self): # A click in the bar chart axis for selection a dimension. - if self.sense_axes != None: + if self.sense_axes is not None: self.sense_axes.cla() self.sense_axes.bar(np.arange(self.model.input_dim), self.model.input_sensitivity(), color='b')