def compute(self, **kwargs):
        """
        Determine the interval to which a district's value belongs.

        @keyword district: A L{District} whose interval should be computed.
        @keyword plan: A L{Plan} whose set of districts should be 
            evaluated for their intervals.
        @keyword version: Optional. The version of the plan, defaults to 
            the most recent version.
        """
        districts = []
        bounds = []
        target = Decimal(str(self.get_value('target')))

        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

        if kwargs in 'district':
            districts = [kwargs['district']]

            # Set up our bounds
            argnum = 1
            while ('bound%d' % argnum) in self.arg_dict:
                bound = Decimal(str(self.get_value('bound%d' % argnum)))
                bounds.append(target + (target * bound))
                bounds.append(target - (target * bound))
                
                argnum += 1
            bounds.sort()
        
            # Check which interval our subject's value is in
            for district in districts:
                value = self.get_value('subject', district)
                if value == None:
                    return
                if apply_num_members and district.num_members > 1:
                    value = value / district.num_members
                
                for idx, bound in enumerate(bounds):
                    if value < bound:
                        self.result = { 
                            'index': idx, 
                            'value': value, 
                            'subject': self.arg_dict['subject'][1]
                        }
                        return
                self.result = {
                    'index': len(bounds), 
                    'value': value, 
                    'subject': self.arg_dict['subject'][1]
                }
                return

        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=True)

            # Set up our bounds
            argnum = 1
            min_bound = None
            while ('bound%d' % argnum) in self.arg_dict:
                bound = Decimal(str(self.get_value('bound%d' % argnum)))
                if (not min_bound) or (bound < min_bound):
                    min_bound = bound
                argnum += 1

            max_bound = target + (target * min_bound)
            min_bound = target - (target * min_bound)

            count = 0
            for district in districts:
                value = self.get_value('subject', district)

                if apply_num_members and district.num_members > 1:
                    value = float(value) / district.num_members
                
                if value != None and value >= min_bound and value < max_bound:
                    count += 1

            self.result = { 'value': count }
        else:
            return
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/calculators.py/Interval.compute/swapped operands of `in`