

def test_expand_dims(self):
    m = np.random.rand(3, 2)
    for d in xrange((m.ndim + 1), (m.ndim * 3)):
        x = mu.expand_dims(np.copy(m), d)
        assert_equals(x.ndim, d)
        assert_equals(x.shape[(x.ndim - m.ndim):], m.shape)
        assert_equals(x.shape[:(x.ndim - m.ndim)], ((1,) * (x.ndim - m.ndim)))
    m = np.random.rand(3, 2, 7)
    for d in xrange((m.ndim + 1), (m.ndim * 3)):
        x = mu.expand_dims(np.copy(m), d)
        assert_equals(x.ndim, d)
        assert_equals(x.shape[(x.ndim - m.ndim):], m.shape)
        assert_equals(x.shape[:(self.ndim - m.ndim)], ((1,) * (x.ndim - m.ndim)))
    m = np.random.rand(3, 2, 7, 1, 2)
    for d in xrange((m.ndim + 1), (m.ndim * 3)):
        x = mu.expand_dims(np.copy(m), d)
        assert_equals(x.ndim, d)
        assert_equals(x.shape[(x.ndim - m.ndim):], m.shape)
        assert_equals(x.shape[:(x.ndim - m.ndim)], ((1,) * (x.ndim - m.ndim)))

dataset/ETHPy150Open kashefy/nideep/nideep/blobs/test_mat_utils.py TestExpandDims.test_expand_dims/VarMisuse@227/240 `x`->`self`