Electronic and magnetic properties of Lu and LuH$_2$