def test_flatten(self): l = [[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]], [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]] l2 = flatten(l) dims = get_shape(l) self.assertEqual(dims, [2, 3, 4]) self.assertNotEqual(l, l2) l3 = _reshape(l2, (2, 3, 4)) self.assertEqual(l, l3) l = [[[], [], []], [[], [], []]] l2 = flatten(l) dims = get_shape(l) self.assertEqual(dims, [2, 3, 0]) l = [1, 2, 3, 4] l2 = flatten(l) dims = get_shape(l) self.assertEqual(dims, [4]) self.assertEqual(l, l2)