From 04be141e64299944fe0fb3aa19ba67e2fb44a7a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 21 Jan 2025 14:54:50 +0100 Subject: [PATCH] doc tweaks in padics --- src/sage/rings/padics/common_conversion.pyx | 20 +++++++++++++------- src/sage/rings/padics/misc.py | 10 +++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/sage/rings/padics/common_conversion.pyx b/src/sage/rings/padics/common_conversion.pyx index 6831fbde141..b6f0dc17e4d 100644 --- a/src/sage/rings/padics/common_conversion.pyx +++ b/src/sage/rings/padics/common_conversion.pyx @@ -1,4 +1,6 @@ r""" +Tools for creation of `p`-adic elements + The functions in this file are used in creating new `p`-adic elements. When creating a `p`-adic element, the user can specify that the absolute @@ -49,7 +51,7 @@ cdef Rational rat_temp = PY_NEW(Rational) cdef long get_ordp(x, PowComputer_class prime_pow) except? -10000: """ - This function determines the valuation of the `p`-adic element + Determine the valuation of the `p`-adic element that will result from the given data ``x``. Note that the valuation can differ depending on the ring: if the @@ -160,7 +162,7 @@ cdef long get_ordp(x, PowComputer_class prime_pow) except? -10000: cdef long get_preccap(x, PowComputer_class prime_pow) except? -10000: """ - This function determines the maximum absolute precision possible + Determine the maximum absolute precision possible for an element created from the given data ``x``. Note that the valuation can differ depending on the ring: if the @@ -231,7 +233,7 @@ cdef long get_preccap(x, PowComputer_class prime_pow) except? -10000: cdef long comb_prec(iprec, long prec) except? -10000: """ - This function returns the minimum of iprec and prec. + Return the minimum of ``iprec`` and ``prec``. INPUT: @@ -255,7 +257,7 @@ cdef long comb_prec(iprec, long prec) except? -10000: cdef int _process_args_and_kwds(long *aprec, long *rprec, args, kwds, bint absolute, PowComputer_class prime_pow) except -1: """ - This function obtains values for absprec and relprec from a + Obtain values for ``absprec`` and ``relprec`` from a combination of positional and keyword arguments. When creating a `p`-adic element, the user can pass in two arguments: ``absprec`` and ``relprec``. @@ -332,7 +334,7 @@ cdef inline long cconv_mpq_t_shared(mpz_t out, mpq_t x, long prec, bint absolute OUTPUT: - - If ``absolute`` is False then returns the valuation that was + - If ``absolute`` is ``False`` then returns the valuation that was extracted (``maxordp`` when `x = 0`). """ cdef long numval, denval @@ -364,6 +366,8 @@ cdef inline int cconv_mpq_t_out_shared(mpq_t out, mpz_t x, long valshift, long p """ Convert the underlying `p`-adic element into a rational. + INPUT: + - ``out`` -- gives a rational approximating the input. Currently uses rational reconstruction but may change in the future to use a more naive method @@ -447,11 +451,11 @@ cdef inline int cconv_shared(mpz_t out, x, long prec, long valshift, PowComputer else: raise NotImplementedError else: - raise NotImplementedError("No conversion defined for %s which is a %s in %s"%(x,type(x),x.parent() if hasattr(x,"parent") else "no parent")) + raise NotImplementedError("No conversion defined for %s which is a %s in %s" % (x, type(x), x.parent() if hasattr(x, "parent") else "no parent")) cdef inline long cconv_mpz_t_shared(mpz_t out, mpz_t x, long prec, bint absolute, PowComputer_class prime_pow) except -2: """ - A fast pathway for conversion of integers that doesn't require + A fast pathway for conversion of integers that does not require precomputation of the valuation. INPUT: @@ -485,6 +489,8 @@ cdef inline int cconv_mpz_t_out_shared(mpz_t out, mpz_t x, long valshift, long p """ Convert the underlying `p`-adic element into an integer if possible. + INPUT: + - ``out`` -- stores the resulting integer as an integer between 0 and `p^{prec + valshift}` - ``x`` -- an ``mpz_t`` giving the underlying `p`-adic element diff --git a/src/sage/rings/padics/misc.py b/src/sage/rings/padics/misc.py index d7ce570a732..3ce3f4f39f9 100644 --- a/src/sage/rings/padics/misc.py +++ b/src/sage/rings/padics/misc.py @@ -14,7 +14,7 @@ - Ander Steele - Kiran Kedlaya (modified gauss_sum 2017/09) """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2007-2013 David Roe # William Stein # @@ -22,8 +22,8 @@ # as published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from sage.rings.infinity import infinity @@ -214,7 +214,7 @@ def precprint(prec_type, prec_cap, p): def trim_zeros(L): r""" - Strips trailing zeros/empty lists from a list. + Strip trailing zeros/empty lists from a list. EXAMPLES:: @@ -228,7 +228,7 @@ def trim_zeros(L): sage: trim_zeros([]) [] - Zeros are also trimmed from nested lists (one deep): + Zeros are also trimmed from nested lists (one deep):: sage: trim_zeros([[1,0]]) [[1]]