qemcmc.coarse_grain =================== .. py:module:: qemcmc.coarse_grain Classes ------- .. autoapisummary:: qemcmc.coarse_grain.CoarseGraining Module Contents --------------- .. py:class:: CoarseGraining(n, subgroups=None, subgroup_probs=None, repeated=True) CoarseGraining class to generate partitions of spins for quantum proposals. :param n: Number of spins in the system. :type n: int :param subgroups: A list of subgroups, where each subgroup is a list of spin indices. If None, the entire set of spins is treated as one subgroup. :type subgroups: list[list[int]], optional :param subgroup_probs: A list of probabilities corresponding to each subgroup, used for weighted random selection. Must sum to 1. If None, subgroups are selected uniformly at random. :type subgroup_probs: list[float], optional :param repeated: If True, then multiple subgroups are run on the quantum computer in serial, if not then only one subgroup is selected at random and run on the quantum computer. Default is ``True``. :type repeated: bool, optional .. py:attribute:: _user_specified .. py:attribute:: n .. py:attribute:: subgroups :value: None .. py:attribute:: subgroup_probs :value: None .. py:attribute:: repeated :value: True .. py:method:: sample() -> list[int] Randomly samples a subgroup according to the specified probability distribution. .. py:method:: get_partitions(m: int) -> list[list[int]] Returns partitions of spins for sequential quantum updates. If the user provided explicit subgroups at initialisation, those are returned directly (all if ``repeated=True``, otherwise just the first). If no subgroups were specified, random disjoint partitions of approximate size n/m are generated. :param m: The number of partitions to generate. Ignored if user-specified subgroups are provided. :type m: int