"""Implements the Runner interface fo LDA
"""

from microscopes.common import validator
from microscopes.common.rng import rng
from microscopes.lda.kernels import lda_crp_gibbs
from microscopes.lda.kernels import lda_sample_dispersion


class runner(object):
    """The LDA runner

    Parameters
    ----------
    defn : ``model_definition``: The structural definition.
    view :  A list of list of serializable objects (the 'documents')
    latent : ``state``: The initialization state.
    """

    def __init__(self, defn, view, latent, kernel_config='assign'):
        self._defn = defn
        self._view = view
        self._latent = latent


    def run(self, r, niters=10000):
        """Run the lda kernel for `niters`, in a single thread.

        Parameters
        ----------
        r : random state
        niters : int

        """
        validator.validate_type(r, rng, param_name='r')
        validator.validate_positive(niters, param_name='niters')

        for _ in xrange(niters):
            lda_crp_gibbs(self._latent, r)
            lda_sample_dispersion(self._latent, r)

@@ -206,37 +206,42 @@
  import 
-lda_sample_dispersion
+sample_gamma, sample_alpha
 %0A%0A%0Aclass
@@ -1062,29 +1062,70 @@
     
-lda_sample_dispersion
+sample_gamma(self._latent, r, 5, 0.1)%0A            sample_alpha
 (sel
@@ -1120,26 +1120,34 @@
 le_alpha(self._latent, r
+, 5, 0.1
 )%0A

Use C++ implementations of hp sampling