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

        @keyword district: A L{District} whose values should be summed.
        @keyword plan: A L{Plan} whose district values should be summed.
        @keyword version: Optional. The version of the plan, defaults to 
            the most recent version.
        @keyword list: A list of values to sum, when summing a set of 
            ScoreArguments.
        """
        districts = []

        if 'district' in kwargs:
            districts = [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)
        elif 'list' in kwargs:
            lst = kwargs['list']
            self.result = {'value': reduce(lambda x,y: x + y, lst)}
            return
        else:
            return
        
        sumvals = 0

        for district in districts:
            argnum = 1
            while ('value%d'%argnum) in self.arg_dict:
                number = self.get_value('value%d'%argnum, district)
                if not number is None:
                    sumvals += number

                argnum += 1

        if self.get_value('target') is not None:
            target = self.get_value('target')
            self.result = { 'value': "%d (of %s)" % (sumvals, target) }
        else:
            self.result = { 'value': sumvals }
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/calculators.py/SumValues.compute/original