lisa-lab/pylearn2 — pull request #1247 by hantek (2014-11-14 23:12:58+00:00)
Title: Write test for from_dataset

Now we have a test code for from_dataset function. It tests if the function can return a DenseDesignMatrix in proper shape while the passed parameter has/has not a y vector of integers. For the current version of from_dataset(), there is no problem dealing with integer "y"s.

However, I find another bug of this function: If the passed DenseDesignMatrix does not define a topological view, it will fail. I don't deem it to be proper because dataset without a topo_view could still return its slice while asked for a slice of it:

>>> dataset = DenseDesignMatrix(X=X, y=y) # X is a 2-d ndarray and y is 1-d vector of labels.
>>> from_dataset(dataset, 5)
Traceback (most recent call last):
File "", line 1, in
File "dense_design_matrix.py", line 1492, in from_dataset
V, y = dataset.get_batch_topo(num_examples, True)
File "dense_design_matrix.py", line 911, in get_batch_topo
rval = self.view_converter.design_mat_to_topo_view(batch_design)
AttributeError: 'NoneType' object has no attribute 'design_mat_to_topo_view'

The culprit is that in the method get_batch_topo(), it is always calling the view_converter, which does not exist while we pass a DenseDesignMatrix with no topo view. Should I fix it?