def compute(self, **kwargs):
        """
        Determine if the requisite number of districts in a plan have a 
        majority of minority population. 

        @keyword plan: A L{Plan} whose set of districts should be 
            evaluated for majority minority compliance.
        @keyword version: Optional. The version of the plan, defaults to
            the most recent version.
        @keyword population: The primary population subject.
        @keyword minorityN: The minorty population subjects. Numbering 
            starts at 1, and must be continuous.
        @keyword threshold: Optional. The ratio of all minorityN 
            populations to the population subject when 'majority' is 
            achieved. Defaults to 0.5.
        @keyword target: Optional. The number of districts required to be 
            valid.
        @keyword validation: Optional. Change the output of the calculator
            to a boolean measure for plan validity.
        """
        if not 'plan' in kwargs:
            return

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

        if 'apply_num_members' in self.arg_dict:
            apply_num_members = int(self.arg_dict['apply_num_members'][1]) == 1
        else:
            apply_num_members = False

        districtcount = 0
        for district in districts:
            pop = self.get_value('population', district)

            if pop is None:
                continue

            den = float(pop)
            argnum = 1
            exceeds = False
            while ('minority%d'%argnum) in self.arg_dict:
                minor = self.get_value('minority%d'%argnum, district)
                argnum += 1

                if minor is None:
                    continue
                    
                num = float(minor)

                try:
                    threshold = float(self.get_value('threshold', district))
                except:
                    threshold = 0.5

                if den != 0 and num / den > threshold:
                    exceeds = True
                    break

            if exceeds:
                if apply_num_members:
                    districtcount += district.num_members
                else:
                    districtcount += 1

        self.result = { 'value': districtcount }

        try:
            target = self.get_value('target')
            validation = self.get_value('validation')
            if validation != None:
                self.result = { 'value': districtcount >= Decimal(validation) }
            elif target != None:
                self.result = { 'value':_('%(value)d (of %(target)s)') % {'value': districtcount, 'target': target} }
        except:
            pass
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/calculators.py/MajorityMinority.compute/original