def _district_calculator(self, district):
        def sum_query(query):
            return sum(map(lambda x: float(x) if x else 0, self.r.mget(query)))
        
        geounit_ids = [geo[1] for geo in district.get_base_geounits()]
        geounit_ids.sort()
        geounit_id_combos = itertools.combinations(geounit_ids, 2)
        redis_query = []
        total = 0
        num_queries = 0
        for count, ids in enumerate(geounit_id_combos):
            num_queries += 1
            if count % 10000 == 0 and count > 0:
                total += sum_query(redis_query)
                redis_query = []
            
            redis_query.append(key_gen(**{'geounit1': ids[0], 'geounit2': ids[1]}))

        total += sum_query(redis_query)

        # return 0 to prevent a divide-by-zero error
        if num_queries == 0:
            return 0

        return num_queries / total
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/calculators.py/Adjacency._district_calculator/swapped operands of `/`