'Test creating a constant.'

def test_constant(self):

    size = (1, 1)
    mat = create_const(1.0, size)
    self.assertEqual(mat.size, size)
    self.assertEqual(len(mat.args), 0)
    self.assertEqual(mat.type, SCALAR_CONST)
    assert (mat.data == 1.0)
    size = (5, 4)
    mat = create_const(np.ones(size), size)
    self.assertEqual(mat.size, size)
    self.assertEqual(len(mat.args), 0)
    self.assertEqual(mat.type, DENSE_CONST)
    assert (mat.data == np.ones(size)).all()
    size = (5, 5)
    mat = create_const(sp.eye(5), size, sparse=True)
    self.assertEqual(mat.size, size)
    self.assertEqual(len(mat.args), 0)
    self.assertEqual(mat.type, SPARSE_CONST)
    assert (mat.data.todense() == sp.eye(5).todense()).all()
