# Path: pygp/utils/models.py
# def get_params(obj):
#     """
#     Helper function which translates the values returned by _params() into
#     something more meaningful.
#     """
#     offset = 0
#     for param in obj._params():
#         key, size, log = param
#         block = slice(offset, offset+size)
#         offset += size
#         yield key, block, log


import numpy as np
from mwhutils.random import rstate
from ..utils.models import get_params
            new_llh = dir_logprob(new_z)
            if np.isnan(new_llh):
                raise Exception("Slice sampler got a NaN")
            if new_llh > llh_s:
                break
            elif new_z < 0:
                lower = new_z
            elif new_z > 0:
                upper = new_z
            else:
                raise Exception("Slice sampler shrank to zero!")

        return new_z*direction + x0

    # FIXME: I've removed how blocks work because I want to rewrite that bit.
    # so right now this samples everything as one big block.
    direction = rng.randn(x0.shape[0])
    direction = direction / np.sqrt(np.sum(direction**2))
    return direction_slice(direction, x0)


#==============================================================================
# interface for sampling hyperparameters from a GP.

def sample(gp, priors, n, raw=True, rng=None):
    rng = rstate(rng)
    priors = dict(priors)
    active = np.ones(gp.nhyper, dtype=bool)
    logged = np.ones(gp.nhyper, dtype=bool)


# Path: pygp/utils/models.py
# def get_params(obj):
#     """
#     Helper function which translates the values returned by _params() into
#     something more meaningful.
#     """
#     offset = 0
#     for param in obj._params():
#         key, size, log = param
#         block = slice(offset, offset+size)
#         offset += size
#         yield key, block, log


# Path: pygp/learning/sampling.py
import numpy as np
from mwhutils.random import rstate
from ..utils.models import get_params

            new_llh = dir_logprob(new_z)
            if np.isnan(new_llh):
                raise Exception("Slice sampler got a NaN")
            if new_llh > llh_s:
                break
            elif new_z < 0:
                lower = new_z
            elif new_z > 0:
                upper = new_z
            else:
                raise Exception("Slice sampler shrank to zero!")

        return new_z*direction + x0

    # FIXME: I've removed how blocks work because I want to rewrite that bit.
    # so right now this samples everything as one big block.
    direction = rng.randn(x0.shape[0])
    direction = direction / np.sqrt(np.sum(direction**2))
    return direction_slice(direction, x0)


#==============================================================================
# interface for sampling hyperparameters from a GP.

def sample(gp, priors, n, raw=True, rng=None):
    rng = rstate(rng)
    priors = dict(priors)
    active = np.ones(gp.nhyper, dtype=bool)
    logged = np.ones(gp.nhyper, dtype=bool)


    for (key, block, log) in get_params(gp):