def compute(self, **kwargs):
        """
        Generate an equivalence score.

        @keyword plan: A L{Plan} whose set of districts should be 
            evaluated for their equivalence.
        @keyword version: Optional. The version of the plan, defaults to 
            the most recent version.
        """
        if 'district' in kwargs or 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 len(districts) == 0:
            return

        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

        min_d = 1000000000 # 1B enough?
        max_d = 0
        for district in districts:
            if district.district_id == 0:
                continue

            tmpval = self.get_value('value',district)
            if apply_num_members and district.num_members > 1:
                tmpval = float(tmpval) / district.num_members
            
            if not tmpval is None:
                min_d = min(float(tmpval), min_d)
                max_d = max(float(tmpval), max_d)

        self.result = { 'value': max_d - min_d }
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/calculators.py/Equivalence.compute/original