def reorder_dictionaries(self):
        """Reorder every dictionaries so as to generate the report properly."""

        buildings = self.buildings.copy()
        self.buildings = reorder_dictionary(buildings, structure_class_order)

        affected_buildings = self.affected_buildings.copy()
        self.affected_buildings = reorder_dictionary(
            affected_buildings, self.categories)
    def reorder_dictionaries(self):
        """Reorder every dictionaries so as to generate the report properly."""

        buildings = self.buildings.copy()
        self.buildings = reorder_dictionary(buildings, structure_class_order)

        affected_buildings = self.affected_buildings.copy()
        self.affected_buildings = reorder_dictionary(affected_buildings,
                                                     self.categories)
Example #3
0
    def reorder_dictionaries(self):
        """Reorder every dictionaries so as to generate the report properly."""
        road_lengths = self.road_lengths.copy()
        self.road_lengths = reorder_dictionary(road_lengths, self.order)

        affected_road_lengths = self.affected_road_lengths.copy()
        self.affected_road_lengths = OrderedDict()
        for key in affected_road_lengths:
            item = affected_road_lengths[key]
            self.affected_road_lengths[key] = reorder_dictionary(
                item, self.order)
    def reorder_dictionaries(self):
        """Reorder every dictionaries so as to generate the report properly."""
        road_lengths = self.road_lengths.copy()
        self.road_lengths = reorder_dictionary(road_lengths, self.order)

        affected_road_lengths = self.affected_road_lengths.copy()
        self.affected_road_lengths = OrderedDict()
        for key in affected_road_lengths:
            item = affected_road_lengths[key]
            self.affected_road_lengths[key] = reorder_dictionary(
                item, self.order)
Example #5
0
    def test_order_dictionary(self):
        """Test if we can reorder a dictionary correctly."""
        unordered = {
            1: 'a',
            2: 'b',
            3: 'c',
            4: 'd',
            5: 'e'
        }
        expected = [5, 4, 3, 2, 1]

        new_dict = reorder_dictionary(unordered, expected)
        self.assertItemsEqual(expected, new_dict.keys())

        # These keys don't exist, but we still show the dictionary
        expected = ['Z', 'X', 'Y']
        new_dict = reorder_dictionary(unordered, expected)
        self.assertEqual(len(new_dict), 5)
    def setup(self, params):
        """concrete implementation it takes care of the needed parameters being
         initialized

        :param params: dict of parameters to pass to the post processor
        """
        AbstractPostprocessor.setup(self, None)
        if (self.impact_total is not None or
                self.impact_attrs is not None or
                self.target_field is not None or
                self.valid_type_fields is not None or
                self.value_mapping is not None or
                self.type_fields is not None):
            self._raise_error('clear needs to be called before setup')

        self.impact_total = params['impact_total']
        self.impact_attrs = params['impact_attrs']
        self.target_field = params['target_field']

        self.value_mapping = reorder_dictionary(
            params['value_mapping'], self._order)

        self.valid_type_fields = params['key_attribute']

        self.type_fields = []
        try:
            for key in self.impact_attrs[0].iterkeys():
                if key.lower() in self.valid_type_fields:
                    self.type_fields.append(key)
        except IndexError:
            pass

        if len(self.type_fields) == 0:
            self.type_fields = None

        # there are no features in this postprocessing polygon
        self.no_features = None
        if len(self.impact_attrs):
            self.no_features = True

        if 'other' not in self.value_mapping.keys():
            self.value_mapping['other'] = []
    def setup(self, params):
        """concrete implementation it takes care of the needed parameters being
         initialized

        :param params: dict of parameters to pass to the post processor
        """
        AbstractPostprocessor.setup(self, None)
        if (self.impact_total is not None or self.impact_attrs is not None
                or self.target_field is not None
                or self.valid_type_fields is not None
                or self.value_mapping is not None
                or self.type_fields is not None):
            self._raise_error('clear needs to be called before setup')

        self.impact_total = params['impact_total']
        self.impact_attrs = params['impact_attrs']
        self.target_field = params['target_field']

        self.value_mapping = reorder_dictionary(params['value_mapping'],
                                                self._order)

        self.valid_type_fields = params['key_attribute']

        self.type_fields = []
        try:
            for key in self.impact_attrs[0].iterkeys():
                if key in self.valid_type_fields:
                    self.type_fields.append(key)
        except IndexError:
            pass

        if len(self.type_fields) == 0:
            self.type_fields = None

        # there are no features in this postprocessing polygon
        self.no_features = None
        if len(self.impact_attrs):
            self.no_features = True

        if 'other' not in self.value_mapping.keys():
            self.value_mapping['other'] = []