def convolve_with_basis(self, S):
        """
        Convolve each column of the event count matrix with this basis
        :param S:     TxK matrix of inputs.
                      T is the number of time bins
                      K is the number of input dimensions.
        :return: TxKxB tensor of inputs convolved with bases
        """
        (T,K) = S.shape
        (R,B) = self.basis.shape


        # Initialize array for filtered stimulus
        F = np.empty((T,K,B))

        # Compute convolutions fo each basis vector, one at a time
        for b in np.arange(B):
            F[:,:,b] = sig.fftconvolve(S,
                                       np.reshape(self.basis[:,b],(R,1)),
                                       'full')[:T,:]

        # Check for positivity
        if np.amin(self.basis) >= 0 and np.amin(S) >= 0:
            np.clip(F, 0, np.inf, out=F)
            assert np.amin(F) >= 0, "convolution should be >= 0"

        return F
dataset/ETHPy150Open slinderman/pyhawkes/pyhawkes/utils/basis.py/Basis.convolve_with_basis/original