homology ranks from complex in sage