There is a bug in the implementation of quadratic_defect function. It persists over a number of versions of Sage. I have Sage 9.5 and 10.3 beta 4 installed, and the bug is in both versions. Here is a minimal example:
Qx.<x> = QQ[]This will throw an exception TypeError: Cannot convert non-integral float to integer
The problem is with the following line in the main loop of this routine:
s = self(q((a - 1) / pi**w)**(1/2))To make the code work it should be replaced with something like this:
s = self( F.lift((q((a - 1) / pi**w)).sqrt()) )Best regards,
P.K.
P.S. Besides, if someone decides to correct this function as explained above, I would also suggest to replace the code
# compute uniformizer piwith just
Let me just comment on your words "searching the source, this routine isn't actually used elsewhere in sage" (here: https://github.com/sagemath/sage/pull/37657). It is not entirely true, because, as far as I know, the method is_padic_square (in the class of a number field element) internally relies on the quadratic_defect.