(self, **kwargs)
Verify that multi-member plans satisfy all parameters.

        @keyword plan: A L{Plan} whose districts should be evaluated for
            multi-member compliance.
        @keyword version: Optional. The version of the plan, defaults to
            the most recent version.
Verify that multi-member plans satisfy all parameters.
Verify that multi - member plans satisfy all parameters .
def compute(self, **kwargs):
        """
        Verify that multi-member plans satisfy all parameters.

        @keyword plan: A L{Plan} whose districts should be evaluated for
            multi-member compliance.
        @keyword version: Optional. The version of the plan, defaults to
            the most recent version.
        """
        self.result = {'value': False}

        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)
        legbod = plan.legislative_body

        if legbod.multi_members_allowed:
            min_dist_mems = legbod.min_multi_district_members
            max_dist_mems = legbod.max_multi_district_members
            min_multi_dists = legbod.min_multi_districts
            max_multi_dists = legbod.max_multi_districts
            min_plan_mems = legbod.min_plan_members
            max_plan_mems = legbod.max_plan_members

            total_members = 0
            total_multi_dists = 0

            for d in districts:
                if d.district_id == 0:
                    continue

                total_members += d.num_members
                if (d.num_members > 1):
                    total_multi_dists += 1

                    # Check number of members per multi-member district
                    if (d.num_members < min_dist_mems) or (d.num_members >
                                                           max_dist_mems):
                        return

            # Check number of multi-member districts
            if (total_multi_dists < min_multi_dists) or (total_multi_dists >
                                                         max_multi_dists):
                return

            # Check number of districts per plan
            if (total_members < min_plan_mems) or (total_members >
                                                   max_plan_mems):
                return

        self.result = {'value': True}
def compute ( self , * * kwargs ) : self . result = { 'value' : False } 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 ) legbod = plan . legislative_body if legbod . multi_members_allowed : min_dist_mems = legbod . min_multi_district_members max_dist_mems = legbod . max_multi_district_members min_multi_dists = legbod . min_multi_districts max_multi_dists = legbod . max_multi_districts min_plan_mems = legbod . min_plan_members max_plan_mems = legbod . max_plan_members total_members = 0 total_multi_dists = 0 for d in districts : if d . district_id == 0 : continue total_members += d . num_members if ( d . num_members > 1 ) : total_multi_dists += 1 # Check number of members per multi-member district if ( d . num_members < min_dist_mems ) or ( d . num_members > max_dist_mems ) : return # Check number of multi-member districts if ( total_multi_dists < min_multi_dists ) or ( total_multi_dists > max_multi_dists ) : return # Check number of districts per plan if ( total_members < min_plan_mems ) or ( total_members > max_plan_mems ) : return self . result = { 'value' : True }