@@ -620,8 +620,10 @@ class GaussianRandomWalkModel(DerivedModel):
620620
621621 :param Model underlying_model: Model representing the likelihood with no
622622 random walk added.
623- :param random_walk_idxs: A list of model parameter indeces to add the
624- random walk to.
623+ :param random_walk_idxs: A list or ``np.slice`` of
624+ ``underlying_model`` model parameter indeces to add the random walk to.
625+ Indeces larger than ``underlying_model.n_modelparams`` should not
626+ be touched.
625627 :param fixed_covariance: An ``np.ndarray`` specifying the fixed covariance
626628 matrix (or diagonal thereof if ``diagonal`` is ``True``) of the
627629 gaussian distribution. If set to ``None`` (default), this matrix is
@@ -649,14 +651,18 @@ def __init__(
649651 ):
650652
651653 self ._diagonal = diagonal
652- self ._rw_idxs = np .arange ( underlying_model .n_modelparams ). astype ( np . int ) \
654+ self ._rw_idxs = np .s_ [: underlying_model .n_modelparams ] \
653655 if random_walk_idxs == 'all' else random_walk_idxs
654656
657+ explicit_idxs = np .arange (underlying_model .n_modelparams )[self ._rw_idxs ]
658+ if explicit_idxs .size == 0 :
659+ raise IndexError ('At least one model parameter must take a random walk.' )
660+
655661 self ._rw_names = [
656662 underlying_model .modelparam_names [idx ]
657- for idx in self . _rw_idxs
663+ for idx in explicit_idxs
658664 ]
659- self ._n_rw = len (self . _rw_idxs )
665+ self ._n_rw = len (explicit_idxs )
660666
661667 self ._srw_names = []
662668 if fixed_covariance is None :
@@ -700,6 +706,9 @@ def __init__(
700706 )
701707
702708 super (GaussianRandomWalkModel , self ).__init__ (underlying_model )
709+
710+ if np .max (np .arange (self .n_modelparams )[self ._rw_idxs ]) > np .max (explicit_idxs ):
711+ raise IndexError ('random_walk_idxs out of bounds; must index (a subset of ) underlying_model modelparams.' )
703712
704713 if scale_mult is None :
705714 self ._scale_mult_fcn = (lambda expparams : 1 )
0 commit comments