pixel_clusterizer/clusterizer.py
def set_hit_fields(self, hit_fields):
        ''' Tell the clusterizer the meaning of the field names.

        The hit_fields parameter is a dict, e.g., {"new field name": "standard field name"}.

        If None default mapping is set.

        Example:
        --------
        Internally, the clusterizer uses the hit fields names "column"/"row". If the name of the hits fields are "x"/"y", call:
        set_hit_fields(hit_fields={'x': 'column',
                                   'y': 'row'})
        '''
        if not hit_fields:
            hit_fields_mapping_inverse = {}
            hit_fields_mapping = {}
        else:
            # Create also the inverse dictionary for faster lookup
            hit_fields_mapping_inverse = dict((k, v) for k, v in hit_fields.items())
            hit_fields_mapping = dict((v, k) for k, v in hit_fields.items())

        for old_name, new_name in self._default_hit_fields_mapping.items():
            if old_name not in hit_fields_mapping:
                hit_fields_mapping[old_name] = new_name
                hit_fields_mapping_inverse[new_name] = old_name

        self._hit_fields_mapping = hit_fields_mapping
        self._hit_fields_mapping_inverse = hit_fields_mapping_inverse
def set_hit_fields(self, hit_fields):
        ''' Tell the clusterizer the meaning of the field names.

        The hit_fields parameter is a dict, e.g., {"new field name": "standard field name"}.

        If None default mapping is set.

        Example:
        --------
        Internally, the clusterizer uses the hit fields names "column"/"row". If the name of the hits fields are "x"/"y", call:
        set_hit_fields(hit_fields={'x': 'column',
                                   'y': 'row'})
        '''
        if not hit_fields:
            hit_fields_mapping_inverse = {}
            hit_fields_mapping = {}
        else:
            # Create also the inverse dictionary for faster lookup
            hit_fields_mapping_inverse = dict((k, v) for k, v in hit_fields.items())
            hit_fields_mapping = dict((v, k) for k, v in hit_fields.items())

        for old_name, new_name in self._default_hit_fields_mapping.items():
            if old_name not in hit_fields_mapping:
                hit_fields_mapping[old_name] = new_name
                hit_fields_mapping_inverse[new_name] = old_name

        self._hit_fields_mapping = hit_fields_mapping
        self._hit_fields_mapping_inverse = hit_fields_mapping_inverse
def set_hit_fields ( self , hit_fields ) : if not hit_fields : hit_fields_mapping_inverse = { } hit_fields_mapping = { } else : # Create also the inverse dictionary for faster lookup hit_fields_mapping_inverse = dict ( ( k , v ) for k , v in hit_fields . items ( ) ) hit_fields_mapping = dict ( ( v , k ) for k , v in hit_fields . items ( ) ) for old_name , new_name in self . _default_hit_fields_mapping . items ( ) : if old_name not in hit_fields_mapping : hit_fields_mapping [ old_name ] = new_name hit_fields_mapping_inverse [ new_name ] = old_name self . _hit_fields_mapping = hit_fields_mapping self . _hit_fields_mapping_inverse = hit_fields_mapping_inverse
Tell the clusterizer the meaning of the field names.

        The hit_fields parameter is a dict, e.g., {"new field name": "standard field name"}.

        If None default mapping is set.

        Example:
        --------
        Internally, the clusterizer uses the hit fields names "column"/"row". If the name of the hits fields are "x"/"y", call:
        set_hit_fields(hit_fields={'x': 'column',
                                   'y': 'row'})
Tell the clusterizer the meaning of the field names .