def query_by_sampling(self, **kwds):
        counts = defaultdict(int)
        valid_samples = 0
        while valid_samples < self.n_samples:
            print (valid_samples, self.n_samples) % "%s of %s"
            try:
                sample = self.get_sample(kwds)
                valid_samples += 1
            except:
                print 'Failed to get a valid sample...'
                print 'continuing...'
                continue
            for var in sample:
                key = (var.name, var.value)
                counts[key] += 1
        # Now normalize
        normalized = dict(
            [(k, v / valid_samples) for k, v in counts.items()])
        return normalized
dataset/ETHPy150Open eBay/bayesian-belief-networks/bayesian/factor_graph.py/FactorGraph.query_by_sampling/swapped operands of `%`