@@ -201,28 +201,28 @@ def rhat(chains, warm_up=0.0):
201201 """
202202 if not (chains .ndim == 2 or chains .ndim == 3 ):
203203 raise ValueError (
204- 'Dimension of chains is %d. ' % chains .ndim
205- + 'Method computes Rhat for one '
206- 'or multiple parameters and therefore only accepts 2 or 3 '
207- 'dimensional arrays.' )
204+ f'Dimension of chains is { chains .ndim } . This method computes Rhat'
205+ ' for one or multiple parameters and therefore only accepts 2 or 3'
206+ ' dimensional arrays.' )
208207 if warm_up > 1 or warm_up < 0 :
209208 raise ValueError (
210- '`warm_up` is set to %f. `warm_up` only takes values in [0,1].' %
211- warm_up )
209+ f'`warm_up` is set to { warm_up } . `warm_up` only takes values in'
210+ ' [0,1].' )
211+ if chains .shape [0 ] < 2 :
212+ raise ValueError ('Number of chains needs to be 2 or higher' )
213+ if chains .shape [1 ] < 1 :
214+ raise ValueError (
215+ 'Number of samples per chain after warm-up and chain splitting is '
216+ f'{ n } . Method needs at least 1 sample per chain.' )
212217
213218 # Get number of samples
214219 n = chains .shape [1 ]
215220
216221 # Exclude warm-up
217222 chains = chains [:, int (n * warm_up ):]
218- n = chains .shape [1 ]
219223
220224 # Split chains in half
221225 n = n // 2 # new length of chains
222- if n < 1 :
223- raise ValueError (
224- 'Number of samples per chain after warm-up and chain splitting is '
225- '%d. Method needs at least 1 sample per chain.' % n )
226226 chains = np .vstack ([chains [:, :n ], chains [:, - n :]])
227227
228228 # Compute mean within-chain variance
0 commit comments