lisa-lab/pylearn2 — pull request #575 by yosinski (2014-02-11 21:24:36+00:00)
Title: Fixed type checking bug.

For a CudaNdarray batch, type(batch) is not equal to the string 'CudaNdarray', so this method of checking type likely never worked. These two lines maybe have been rarely encountered, so this bug probably went unnoticed.

For reference, here is a little poking around in pdb after catching the error in the original code:

```
TypeError: The value of a Conv2DSpace batch should be a numpy.ndarray,
or CudaNdarray, but is .

ipdb> l
796 def _np_validate(self, batch):
797 if (not isinstance(batch, np.ndarray)
798 and type(batch) != 'CudaNdarray'):
799 raise TypeError("The value of a Conv2DSpace batch
should be a "
800 "numpy.ndarray, or CudaNdarray, but is %s."
--> 801 % str(type(batch)))
802 if batch.ndim != 4:
803 raise ValueError("The value of a Conv2DSpace batch must be "
804 "4D, got %d dimensions for %s." %
805 (batch.ndim, batch))
806

ipdb> type(batch)

ipdb> type(type(batch))

ipdb> type(batch) == 'CudaNdarray'
False
```