gh-37257: `sage.groups.generic`: Fix incorrect identity testing
The `bsgs` function used to check `is_zero`, when it should check `==
identity` (which is given). It also allows me to use the method for "ad-
hoc classes":
```sage
sage: # modulo arithmetic lmao
....: # I'll just carry around the modulus
....: n = int(12)
....: G_id = (int(0), n)
....: G_gen = (int(1), n)
....: def G_op(P, Q):
....: return (int((P[0] + Q[0]) % P[1]), P[1])
....: def G_inv(P):
....: return (int(-P[0] % P[1]), P[1])
....: P = (int(5), n)
....:
....: from sage.groups.generic import discrete_log
....: discrete_log(P, G_gen, operation=None, ord=n, op=G_op,
identity=G_id, inverse=G_inv)
```
Also fixed styling, that's why there are some random edits
URL: https://github.com/sagemath/sage/pull/37257
Reported by: grhkm21
Reviewer(s): grhkm21, Lorenz Panny