def testIteratorFunc2(self): dataset = FlixsterDataset() trainIterator = dataset.getTrainIteratorFunc() testIterator = dataset.getTestIteratorFunc() for trainX in trainIterator: testX = testIterator.next() print(trainX.shape, trainX.nnz, testX.nnz) self.assertEquals(trainX.shape, testX.shape)
def testData2(self): #Check numbers of rows/cols of matrix dataset = FlixsterDataset() trainIterator = dataset.getTrainIteratorFunc() X = trainIterator.next() rowInds, colInds = X.nonzero() print("Counting rows") rowCounts = numpy.bincount(rowInds) colCounts = numpy.bincount(colInds) print("Done counting rows") print((colCounts<5000).sum(), X.shape[1])
def testIteratorFunc3(self): #Check to see if repeated calls generate new matrices iterStartTimeStamp = time.mktime(datetime(2005,1,1).timetuple()) dataset = FlixsterDataset(iterStartTimeStamp=iterStartTimeStamp) trainIterator = dataset.getTrainIteratorFunc() X = next(trainIterator) X.data += 1 trainIterator = dataset.getTrainIteratorFunc() X2 = next(trainIterator) nptst.assert_array_almost_equal(X.data, X2.data+1)