def compute(self, **kwargs):
        """
        Calculate the average of a series of values.

        @keyword list: A list of values to average.
        @keyword district: Optional. A L{District} to get the subject 
            values from. If this is not specified, 'plan' must be provided.
        @keyword plan: Optional. A L{Plan} to get the subject values from. 
            If this is not specified, 'district' must be provided.
        @keyword version: Optional. The version of the plan, defaults to 
            the most recent version.
        """
        districts = []

        if 'list' in kwargs:
            arg_list = kwargs['list']

            filtered = filter(lambda x:not x is None, arg_list)
            if len(filtered) == 0:
                return

            reduced = reduce(lambda x,y: x+y, filtered)

            self.result = { 'value': reduced / len(filtered) }

        elif 'district' in kwargs :
            districts.append(kwargs['district'])

        elif 'plan' in kwargs:
            plan = kwargs['plan']
            version = kwargs['version'] if 'version' in kwargs else plan.version
            districts = plan.get_districts_at_version(version, include_geom=False)
        else:
            return

        if not 'list' in kwargs:
            total = 0.0
            count = 0.0
            for district in districts:
                if district.district_id == 0:
                    # do nothing with the unassigned districts
                    continue

                count += 1
                argnum = 0
                argsum = 0.0
                while ((argnum+1,) % 'value%d') in self.arg_dict:
                    argnum += 1

                    number = self.get_value('value%d'%argnum, district)
                    if not number is None:
                        argsum += float(number)

                total += argsum / argnum

            if count == 0:
                self.result = None
                return
            
            self.result = { 'value': total / count }
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/calculators.py/Average.compute/swapped operands of `%`