def testRestrictOmega(self): m = 50 n = 100 k = 5 u = 0.5 w = 1 - u X = SparseUtils.generateSparseBinaryMatrix((m, n), k, w, csarray=True) indPtr, colInds = SparseUtils.getOmegaListPtr(X) runs = 100 for i in range(runs): colSubset = numpy.random.choice(n, 20, replace=False) newIndPtr, newColInds = restrictOmega(indPtr, colInds, colSubset) for i in range(m): omegai = colInds[indPtr[i]:indPtr[i + 1]] omegai2 = newColInds[newIndPtr[i]:newIndPtr[i + 1]] a = numpy.setdiff1d(omegai, omegai2) self.assertEquals(numpy.intersect1d(a, colSubset).shape[0], 0)
def testRestrictOmega(self): m = 50 n = 100 k = 5 u = 0.5 w = 1-u X = SparseUtils.generateSparseBinaryMatrix((m, n), k, w, csarray=True) indPtr, colInds = SparseUtils.getOmegaListPtr(X) runs = 100 for i in range(runs): colSubset = numpy.random.choice(n, 20, replace=False) newIndPtr, newColInds = restrictOmega(indPtr, colInds, colSubset) for i in range(m): omegai = colInds[indPtr[i]:indPtr[i+1]] omegai2 = newColInds[newIndPtr[i]:newIndPtr[i+1]] a = numpy.setdiff1d(omegai, omegai2) self.assertEquals(numpy.intersect1d(a, colSubset).shape[0], 0)
def run(): for i in range(100): newIndPtr, newColInds = restrictOmega(indPtr, colInds, colIndsSubset)