def Z2_to_sign(f): """ Helper function turning the result of get_all_obstruction_classes which uses the type field_p into +1, -1 signs. >>> Z2_to_sign(field_p(2)(0)) 1 >>> Z2_to_sign(field_p(2)(1)) -1 """ if f == field_p(2)(0): return + 1 elif f == field_p(2)(1): return - 1 raise Exception, "Z2_to_sign expects field_p(2)(0) or field_p(2)(1)"
def get_all_obstruction_classes(t): """ Computes all classes in H^2(M, partial M; Z/2) """ return cohomology_2_rel_boundary_classes(t, field_p(2))