"""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 sample_gamma, sample_alpha


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)
            sample_gamma(self._latent, r, 5, 0.1)
            sample_alpha(self._latent, r, 5, 0.1)

"""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)

--- 
+++ 
@@ -4,7 +4,7 @@
 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
+from microscopes.lda.kernels import sample_gamma, sample_alpha
 
 
 class runner(object):
@@ -37,4 +37,5 @@
 
         for _ in xrange(niters):
             lda_crp_gibbs(self._latent, r)
-            lda_sample_dispersion(self._latent, r)
+            sample_gamma(self._latent, r, 5, 0.1)
+            sample_alpha(self._latent, r, 5, 0.1)
Use C++ implementations of hp sampling
