def domain(self, expparams): """ Returns a list of :class:`Domain` objects, one for each input expparam. :param numpy.ndarray expparams: Array of experimental parameters. This array must be of dtype agreeing with the ``expparams_dtype`` property. :rtype: list of ``Domain`` """ return [ MultinomialDomain(n_elements=self.n_sides, n_meas=ep['n_meas']) for ep in expparams ]
def __init__(self, underlying_model): super(MultinomialModel, self).__init__(underlying_model) if isinstance(underlying_model.expparams_dtype, str): # We default to calling the original experiment parameters "x". self._expparams_scalar = True self._expparams_dtype = [('x', underlying_model.expparams_dtype), ('n_meas', 'uint')] else: self._expparams_scalar = False self._expparams_dtype = underlying_model.expparams_dtype + [ ('n_meas', 'uint') ] # Demand that the underlying model always has the same number of outcomes # This assumption could in principle be generalized, but not worth the effort now. assert (self.underlying_model.is_n_outcomes_constant) self._underlying_domain = self.underlying_model.domain(None) self._n_sides = self._underlying_domain.n_members # Useful for getting the right type, etc. self._example_domain = MultinomialDomain(n_elements=self.n_sides, n_meas=3)