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


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

    Parameters
    ----------
    defn : ``model_definition``
        The structural definition.

    view : dataview
        A list of list of serializable objects (the 'documents')

    latent : ``state``
        The initialization state.

    kernel_config : list

    """

    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 specified 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)<commit_msg>Update docstrings for model runner<commit_after>"""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


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.

    kernel_config : list

    """

    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)
{'fraction_non_alphanumeric': 0.10941121928604543, 'fraction_numerical': 0.004636068613815485, 'mean_word_length': 2.4037854889589907, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2100819', 'n_tokens_mistral': 669, 'n_tokens_neox': 623, 'n_words': 181}