Exemplo n.º 1
0
    def make_new_coincidence(self, uNodeState, uFirstCoinc=False):
        """Make a new coincidence and updates the size of the node's internal matrices."""
        input_msg = uNodeState['input_msg']

        if uFirstCoinc:
            coincidences = np.array([compute_widx(input_msg)], dtype=np.uint16)
            k = 0
            seen = np.array([1])
            TAM = np.array([[0]], dtype=np.uint16)
            
        else:
            coincidences = uNodeState['coincidences']
            TAM = uNodeState['TAM']
            seen = uNodeState['seen']

            (rows, cols) = coincidences.shape
            new_coincidences = np.zeros((rows + 1, cols), dtype=np.uint16)
            new_coincidences[:rows,:cols] = coincidences
            new_coincidences[rows,:] = compute_widx(input_msg)
            coincidences = new_coincidences

            (k, _) = coincidences.shape
            k -= 1

            (cols,) = seen.shape
            new_seen = np.zeros(cols + 1)
            new_seen[:cols] = seen
            seen = new_seen
            
            ## resize TAM
            TAM = utils.inc_rows_cols(TAM)
            
        ## update the node's state
        uNodeState['coincidences'] = coincidences
        uNodeState['seen'] = seen
        uNodeState['TAM'] = TAM
        
        return k