# Ticket #13062: 13062_nodoctest_review.patch

File 13062_nodoctest_review.patch, 10.8 KB (added by jdemeyer, 9 years ago)
• ## doc/en/developer/conventions.rst

# HG changeset patch
# User Jeroen Demeyer <jdemeyer@cage.ugent.be>
# Date 1364414417 25200
# Node ID 3839d3478432627117955b74230efb7cb057e1d8
# Parent  7667d2d4c6348ca6ac011d35c4c488d56883cabe
Fix nodoctest parsing

diff --git a/doc/en/developer/conventions.rst b/doc/en/developer/conventions.rst
 a It is also immediately clear to the user that the indicated example does not currently work. - If one of the first 10 lines of a file starts with r""" nodoctest (or """ nodoctest or # nodoctest or % nodoctest or .. nodoctest, or any of these with different spacing), then that file will be skipped. If a directory contains a file nodoctest.py, then that whole directory will be skipped. Neither of this applies to files or directories which are explicitly given as command line arguments: those are always tested. - If a line contains # optional - PKGNAME (where the # may be any non-letter non-space character), it is not tested unless the --optional=PKGNAME flag is passed to sage -t.
• ## sage/all_cmdline.py

diff --git a/sage/all_cmdline.py b/sage/all_cmdline.py
 a #                  http://www.gnu.org/licenses/ ############################################################################# """nodoctest""" sage_mode = 'cmdline' try:
• ## sage/all_notebook.py

diff --git a/sage/all_notebook.py b/sage/all_notebook.py
 a """nodoctest""" from sage.all import * preparser(on=True)
• ## sage/databases/all.py

diff --git a/sage/databases/all.py b/sage/databases/all.py
• ## sage/databases/lincodes.py

diff --git a/sage/databases/lincodes.py b/sage/databases/lincodes.py
 a """nodoctest """ Linear codes """
• ## sage/doctest/control.py

diff --git a/sage/doctest/control.py b/sage/doctest/control.py
 a from reporting import DocTestReporter from util import NestedName, Timer, count_noun, dict_difference nodoctest_regex = re.compile(r'\s*(#+|%+|\.\.)\s*nodoctest') nodoctest_regex = re.compile(r'\s*(#+|%+|r"+|"+|\.\.)\s*nodoctest') class DocTestDefaults(SageObject): """ sage: DC.expand_files_into_sources() sage: DC.sources [] The directory sage/doctest/tests contains nodoctest.py but the files should still be tested when that directory is explicitly given (as opposed to being recursed into):: sage: DC = DocTestController(DD, [os.path.join(SAGE_SRC, 'sage', 'doctest', 'tests')]) sage: DC.expand_files_into_sources() sage: len(DC.sources) >= 10 True """ def skipdir(dirname): if os.path.exists(os.path.join(dirname, "nodoctest.py")):
• ## sage/schemes/all.py

diff --git a/sage/schemes/all.py b/sage/schemes/all.py
 a """nodoctest """ all.py -- export of schemes to Sage """
• ## deleted file sage/schemes/generic/notes/divisor_stein-joyner.txt

diff --git a/sage/schemes/generic/notes/divisor_stein-joyner.txt b/sage/schemes/generic/notes/divisor_stein-joyner.txt
deleted file mode 100644
 + """nodoctest Divisors AUTHORS: -- William Stein -- David Kohel -- David Joyner EXAMPLES: sage: x,y,z = ProjectiveSpace(2, GF(5), names='xyz').gens() sage: C = Curve(y^2*z^7 - x^9 - x*z^8) sage: pts = C.rational_points(); pts [(0 : 0 : 1), (0 : 1 : 0), (2 : 2 : 1), (2 : 3 : 1), (3 : 1 : 1), (3 : 4 : 1)] sage: D = C.divisor(pts[0])*3 - C.divisor(pts[1]) + C.divisor(pts[5])*10; D 3*(0 : 0 : 1) - (0 : 1 : 0) + 10*(3 : 4 : 1) sage: D[1][0] -1 sage: D[1][1] (0 : 1 : 0) sage: C.divisor([(3, pts[0]), (-1, pts[1]), (10,pts[5])]) 3*(0 : 0 : 1) - (0 : 1 : 0) + 10*(3 : 4 : 1) """ #******************************************************************************* #  Copyright (C) 2005 David Kohel #  Copyright (C) 2005 William Stein # #  Distributed under the terms of the GNU General Public License (GPL) # #  The full text of the GPL is available at: # #                  http://www.gnu.org/licenses/ #******************************************************************************* from sage.structure.all import FormalSum from sage.groups.group import AbelianGroup from sage.rings.all import Z class Divisor_generic(FormalSum): def scheme(self): """ Return the scheme that this divisor is on. EXAMPLES: sage: x,y = AffineSpace(2, GF(5), names='xyz').gens() sage: C = Curve(y^2 - x^9 - x) sage: pts = C.rational_points(); pts [(0, 0), (2, 2), (2, 3), (3, 1), (3, 4)] sage: D = C.divisor(pts[0])*3 - C.divisor(pts[1]); D 3*(0, 0) - (2, 2) sage: D.scheme() Closed subscheme of Affine Space of dimension 2 over Finite Field of size 5 defined by: xyz_1^2 + 4*xyz_0 + 4*xyz_0^9 """ return self.parent().scheme() class Divisor_curve_points(Divisor_generic): r""" For any curve $C$, use \code{C.divisor(v)} to construct a divisor on $C$.  Here $v$ can be either \begin{itemize} \item a rational point on $C$ \item a list of rational points \item a list of 2-tuples $(c,P)$, where $c$ is an integer and $P$ is a rational point. \end{itemize} TODO: Divisors shouldn't be restricted to rational points.  The problem is that the divisor group is the formal sum of the group of points on the curve, and there's no implemented notion of point on $E/K$ that has coordinates in $L$.   This is what should be implemented, by adding an appropriate class to \code{schemes/generic/morphism.py}. EXAMPLES: sage: E = EllipticCurve([0, 0, 1, -1, 0]) sage: P = E(0,0) sage: 10*P (161/16 : -2065/64 : 1) sage: D = E.divisor(P) sage: D (0 : 0 : 1) sage: 10*D 10*(0 : 0 : 1) sage: E.divisor([P, P]) 2*(0 : 0 : 1) sage: E.divisor([(3,P), (-4,5*P)]) 3*(0 : 0 : 1) - 4*(1/4 : -5/8 : 1) """ def __init__(self, v, check=True, reduce=True): """ INPUT: v -- a list of pairs (c, P), where c is an integer and P is a point on a curve.  The P's must all lie on the same curve. To create the 0 divisor use [(0, P)], so as to give the curve. """ if not isinstance(v, (list, tuple)): v = [(1,v)] if len(v) < 1: raise ValueError, "v (=%s) must have length at least 1"%v if not (isinstance(v[0], tuple) and len(v[0]) == 2): C = v[0].scheme() else: C = v[0][1].scheme() if check: w = [] for t in v: if isinstance(t, tuple) and len(t) == 2: w.append((Z(t[0]), C(t[1]))) else: w.append((Z(1), C(t))) v = w Divisor_generic.__init__(self, v, check=False, reduce=True, parent = DivisorGroup(C)) class DivisorGroup(AbelianGroup): def __init__(self, scheme): self.__scheme = scheme def _repr_(self): return "Group of Divisors on %s"%self.__scheme def __cmp__(self, right): if not isinstance(right, DivisorGroup): return -1 return cmp(self.__scheme, right.__scheme) def scheme(self): return self.__scheme class DivisorGroup_curve_points(DivisorGroup): def __call__(self, v): return Divisor_curve_points(v)
• ## sage/tests/all.py

diff --git a/sage/tests/all.py b/sage/tests/all.py
 a """nodoctest """ from sage.modular.modsym.tests import Test as modsym from sage.tests.arxiv_0812_2725 import *