From 244bda07d92d1306f8e674c4bd716383681d2bcd Mon Sep 17 00:00:00 2001 From: antcc Date: Tue, 30 Jul 2024 19:52:05 +0200 Subject: [PATCH 1/5] Add axis=2 in squeeze logic --- eryn/backends/backend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eryn/backends/backend.py b/eryn/backends/backend.py index 47eb6e2..5f4e8cf 100644 --- a/eryn/backends/backend.py +++ b/eryn/backends/backend.py @@ -741,7 +741,7 @@ def get_gelman_rubin_convergence_diagnostic( if chains.shape[2] == 1: # If no multiple leaves, we squeeze and transpose to the # right shape to pass to the psrf function, which is (nwalkers, nsamples, ndim) - chains_in = chains.squeeze().transpose((1, 0, 2)) + chains_in = chains.squeeze(axis=2).transpose((1, 0, 2)) else: # Project onto the model dim all chains [in case of RJ and multiple leaves per branch] inds = self.get_inds(discard=discard, thin=thin)[branch][ From db9eea19ad3c06ccab3b4ec6f1a3711afa653586 Mon Sep 17 00:00:00 2001 From: antcc Date: Tue, 30 Jul 2024 19:52:29 +0200 Subject: [PATCH 2/5] Remove duplicated update_fn logic in run_mcmc --- eryn/ensemble.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/eryn/ensemble.py b/eryn/ensemble.py index 2e83ca0..2f10b5d 100644 --- a/eryn/ensemble.py +++ b/eryn/ensemble.py @@ -956,6 +956,8 @@ def sample( ) # update after diagnostic and stopping check + # if updating and using burn_in, need to make sure it does not use + # previous chain samples since they are not stored. if ( self.update_iterations > 0 and self.update_fn is not None @@ -1004,9 +1006,6 @@ def run_mcmc( ) initial_state = self._previous_state - # setup thin_by info - thin_by = 1 if "thin_by" not in kwargs else kwargs["thin_by"] - # run burn in if burn is not None and burn != 0: # prepare kwargs that relate to burn @@ -1015,14 +1014,6 @@ def run_mcmc( burn_kwargs["thin_by"] = 1 i = 0 for results in self.sample(initial_state, iterations=burn, **burn_kwargs): - # if updating and using burn_in, need to make sure it does not use - # previous chain samples since they are not stored. - if ( - self.update_iterations > 0 - and self.update_fn is not None - and (i + 1) % (self.update_iterations * thin_by) == 0 - ): - self.update_fn(i, results, self) i += 1 # run post-burn update From de1d0f81abbeb142786db89cbf35ab9d5bf3786d Mon Sep 17 00:00:00 2001 From: antcc Date: Tue, 30 Jul 2024 19:53:04 +0200 Subject: [PATCH 3/5] Make a copy of the accepted array --- eryn/moves/combine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eryn/moves/combine.py b/eryn/moves/combine.py index 5741177..3ab052d 100644 --- a/eryn/moves/combine.py +++ b/eryn/moves/combine.py @@ -45,7 +45,7 @@ def accepted(self, accepted): # set the accepted arrays for all moves assert isinstance(accepted, np.ndarray) for move in self.moves: - move.accepted = accepted + move.accepted = accepted.copy() @property def acceptance_fraction(self): From 119de0b4d8c79e3b22bba5eaca58fa51aeddce3b Mon Sep 17 00:00:00 2001 From: antcc Date: Tue, 30 Jul 2024 19:53:39 +0200 Subject: [PATCH 4/5] Remove duplicate setup_friends condition --- eryn/moves/group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eryn/moves/group.py b/eryn/moves/group.py index b7d1f41..5f8e44c 100644 --- a/eryn/moves/group.py +++ b/eryn/moves/group.py @@ -130,7 +130,7 @@ def propose(self, model, state): # Run any move-specific setup. self.setup(state.branches) - if self.iter == 0 or self.iter % self.n_iter_update == 0: + if self.iter == 0: self.setup_friends(state.branches) if self.iter != 0 and self.iter % self.n_iter_update == 0: From 02a9d8fddc5ba998dd9fc245ef34efd816b36d1f Mon Sep 17 00:00:00 2001 From: Michael Katz Date: Mon, 26 Aug 2024 10:45:11 -0500 Subject: [PATCH 5/5] Update group.py --- eryn/moves/group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eryn/moves/group.py b/eryn/moves/group.py index 5f8e44c..b7d1f41 100644 --- a/eryn/moves/group.py +++ b/eryn/moves/group.py @@ -130,7 +130,7 @@ def propose(self, model, state): # Run any move-specific setup. self.setup(state.branches) - if self.iter == 0: + if self.iter == 0 or self.iter % self.n_iter_update == 0: self.setup_friends(state.branches) if self.iter != 0 and self.iter % self.n_iter_update == 0: