@@ -243,16 +243,9 @@ def get_pseudo_likelihood_cost(self, updates):
243243 fe_xi = self .free_energy (xi )
244244
245245 # flip bit x_i of matrix xi and preserve all other bits x_{\i}
246- # Equivalent to xi[:,bit_i_idx] = 1-xi[:, bit_i_idx]
247- # NB: slice(start,stop,step) is the python object used for
248- # slicing, e.g. to index matrix x as follows: x[start:stop:step]
249- # In our case, idx_list is a tuple. The first element of the tuple
250- # describes what slice we want from the first dimension.
251- # ``slice(None,None,None)`` means that we want all values, equivalent
252- # to numpy notation ``:``. The second element of the tuple is the
253- # value bit_i_idx, meaning that we are looking for [:,bit_i_idx].
254- xi_flip = T .setsubtensor (xi , 1 - xi [:, bit_i_idx ],
255- idx_list = (slice (None ,None ,None ),bit_i_idx ))
246+ # Equivalent to xi[:,bit_i_idx] = 1-xi[:, bit_i_idx], but assigns
247+ # the result to xi_flip, instead of working in place on xi.
248+ xi_flip = T .set_subtensor (xi [:,bit_i_idx ], 1 - xi [:,bit_i_idx ])
256249
257250 # calculate free energy with bit flipped
258251 fe_xi_flip = self .free_energy (xi_flip )
0 commit comments