code
stringlengths
17
6.64M
class Profiler(): '\n Keeps track of CPU time used between a series of user-defined checkpoints.\n\n It\'s probably not a good idea to use this class in an inner loop :-)\n\n EXAMPLES::\n\n from sage.misc.profiler import Profiler\n sage: def f(): # not tested\n ...
class Python(): '\n Allows for evaluating a chunk of code without any preparsing.\n ' def eval(self, x, globals, locals=None): '\n Evaluate x with given globals; locals is completely ignored.\n\n This is specifically meant for evaluating code blocks with\n ``%python`` in th...
def random_testing(fn): '\n This decorator helps create random testers. These can be run as\n part of the standard Sage test suite; everybody who runs the test\n will use a different random number seed, so many different random\n tests will eventually be run.\n\n INPUT:\n\n - ``fn`` - The f...
@random_testing def test_add_commutes(trials, verbose=False): '\n This is a simple demonstration of the :func:`random_testing` decorator and\n its recommended usage.\n\n We test that addition is commutative over rationals.\n\n EXAMPLES::\n\n sage: from sage.misc.random_testing import test_add_c...
@random_testing def test_add_is_mul(trials, verbose=False): '\n This example demonstrates a failing :func:`random_testing` test,\n and shows how to reproduce the error.\n\n DO NOT USE THIS AS AN EXAMPLE OF HOW TO USE\n :func:`random_testing`! Instead, look at\n :func:`sage.misc.random_testing.test...
def get_remote_file(filename, verbose=True): '\n INPUT:\n\n - ``filename`` -- the URL of a file on the web, e.g.,\n ``"http://modular.math.washington.edu/myfile.txt"``\n\n - ``verbose`` -- whether to display download status\n\n OUTPUT:\n\n creates a file in the temp directory and returns the a...
def find_replacements(location, package_regex=None, verbose=False): "\n Locate the lines in the file at ``location`` which contain an ``import`` statement.\n\n INPUT:\n\n - ``location`` -- a file path\n - ``package_regex`` -- (default: :obj:`default_package_regex`) a regular expression matching\n ...
def process_line(location, line, replacements, row_index, verbose=False): '\n Modify a single source code ``line`` according to the given ``replacements``.\n\n INPUTS:\n\n - ``location`` -- a file path; only used for logging\n - ``line`` -- a source code line\n - ``replacements`` -- the array outpu...
def make_replacements_in_file(location, package_regex=None, verbose=False, output=None): '\n Replace ``import`` statements in the file with filepath "location".\n\n INPUT:\n\n - ``location`` -- a file path\n - ``package_regex`` -- (default: :obj:`default_package_regex`) a regular expression matching\n...
def walkdir_replace_dot_all(dir, file_regex='.*[.](py|pyx|pxi)$', package_regex=None, verbose=False, *, excluded_file_regex='auto-methods|replace_dot_all'): "\n Replace ``import`` statements in the files in directory ``dir`` matching the regex pattern ``file_regex``.\n\n INPUTS:\n\n - ``dir`` -- a direct...
def coeff_repr(c, is_latex=False): "\n String representing coefficients in a linear combination.\n\n INPUT:\n\n - ``c`` -- a coefficient (i.e., an element of a ring)\n\n OUTPUT:\n\n A string\n\n EXAMPLES::\n\n sage: from sage.misc.repr import coeff_repr\n sage: coeff_repr(QQ(1/2))\...
def repr_lincomb(terms, is_latex=False, scalar_mult='*', strip_one=False, repr_monomial=None, latex_scalar_mult=None): '\n Compute a string representation of a linear combination of some\n formal symbols.\n\n INPUT:\n\n - ``terms`` -- list of terms, as pairs (support, coefficient)\n - ``is_latex`` ...
def gen_rest_table_index(obj, names=None, sort=True, only_local_functions=True, root=None): '\n Return a ReST table describing a list of functions.\n\n The list of functions can either be given explicitly, or implicitly as the\n functions/methods of a module or class.\n\n In the case of a class, only ...
def list_of_subfunctions(root, only_local_functions=True): "\n Return the functions (resp. methods) of a given module (resp. class) with their names.\n\n INPUT:\n\n - ``root`` -- the module, or class, whose elements are to be listed.\n\n - ``only_local_functions`` -- boolean (default: ``True``); if ``...
def gen_thematic_rest_table_index(root, additional_categories=None, only_local_functions=True): "\n Return a ReST string of thematically sorted functions (or methods) of a\n module (or class).\n\n INPUT:\n\n - ``root`` -- the module, or class, whose elements are to be listed.\n\n - ``additional_cat...
def doc_index(name): '\n Attribute an index name to a function.\n\n This decorator can be applied to a function/method in order to specify in\n which index it must appear, in the index generated by\n :func:`gen_thematic_rest_table_index`.\n\n INPUT:\n\n - ``name`` -- a string, which will become ...
def sage_eval(source, locals=None, cmds='', preparse=True): '\n Obtain a Sage object from the input string by evaluating it using\n Sage. This means calling eval after preparsing and with globals\n equal to everything included in the scope of ``from sage.all\n import *``.).\n\n INPUT:\n\n\n - `...
def sageobj(x, vars=None): "\n Return a native Sage object associated to ``x``, if possible and\n implemented.\n\n If the object has a ``_sage_`` method it is called and the value is\n returned. Otherwise, :func:`str` is called on the object, and all preparsing\n is applied and the resulting expres...
def sage_input(x, preparse=True, verify=False, allow_locals=False): "\n Return a sequence of commands that can be used to rebuild the object ``x``.\n\n INPUT:\n\n - ``x`` - the value we want to find an input form for\n\n - ``preparse`` - (default ``True``) Whether to generate code that requires\n ...
class SageInputBuilder(): '\n An instance of this class is passed to ``_sage_input_`` methods.\n It keeps track of the current state of the ``_sage_input_`` process,\n and contains many utility methods for building :class:`SageInputExpression`\n objects.\n\n In normal use, instances of :class:`Sage...
class SageInputExpression(): '\n Subclasses of this class represent expressions for :func:`sage_input`.\n \\sage classes should define a \\method{_sage_input_} method, which\n will return an instance of :class:`SageInputExpression`, created using\n methods of :class:`SageInputBuilder`.\n\n To the e...
class SIE_literal(SageInputExpression): '\n An abstract base class for ``literals`` (basically, values which\n consist of a single token).\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputBuilder, SIE_literal\n\n sage: sib = SageInputBuilder()\n sage: sie = sib(3)\n...
class SIE_literal_stringrep(SIE_literal): "\n Values in this class are leaves in a :func:`sage_input` expression\n tree. Typically they represent a single token, and consist of the\n string representation of that token. They are used for integer,\n floating-point, and string literals, and for name e...
class SIE_call(SageInputExpression): "\n This class represents a function-call node in a :func:`sage_input`\n expression tree.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputBuilder\n\n sage: sib = SageInputBuilder()\n sage: sie = sib.name('GF')\n sage: sie...
class SIE_subscript(SageInputExpression): "\n This class represents a subscript node in a :func:`sage_input`\n expression tree.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputBuilder\n\n sage: sib = SageInputBuilder()\n sage: sie = sib.name('QQ')['x,y']\n s...
class SIE_getattr(SageInputExpression): "\n This class represents a getattr node in a :func:`sage_input`\n expression tree.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputBuilder\n\n sage: sib = SageInputBuilder()\n sage: sie = sib.name('CC').gen()\n sage: ...
class SIE_tuple(SageInputExpression): '\n This class represents a tuple or list node in a :func:`sage_input`\n expression tree.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputBuilder\n\n sage: sib = SageInputBuilder()\n sage: sib((1, \'howdy\'))\n {tuple: (...
class SIE_dict(SageInputExpression): "\n This class represents a dict node in a :func:`sage_input`\n expression tree.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputBuilder\n\n sage: sib = SageInputBuilder()\n sage: sib.dict([('TeX', RR(pi)), ('Metafont', RR(e))])...
class SIE_binary(SageInputExpression): '\n This class represents an arithmetic expression with a binary operator\n and its two arguments, in a :func:`sage_input` expression tree.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputBuilder\n\n sage: sib = SageInputBuilder()\n ...
class SIE_unary(SageInputExpression): '\n This class represents an arithmetic expression with a unary operator\n and its argument, in a :func:`sage_input` expression tree.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputBuilder\n\n sage: sib = SageInputBuilder()\n ...
class SIE_gens_constructor(SageInputExpression): '\n This class represents an expression that can create a \\sage parent\n with named generators, optionally using the \\sage preparser\n generators syntax (like ``K.<x> = QQ[]``).\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInpu...
class SIE_gen(SageInputExpression): "\n This class represents a named generator of a parent with named\n generators.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputBuilder\n\n sage: sib = SageInputBuilder()\n sage: sib.gen(ZZ['x'])\n {gen:x {constr_parent: ...
class SIE_import_name(SageInputExpression): "\n This class represents a name which has been imported from a module.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputBuilder\n\n sage: sib = SageInputBuilder()\n sage: sib.import_name('sage.rings.integer', 'make_integer')...
class SIE_assign(SageInputExpression): "\n This class represents an assignment command.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputBuilder\n\n sage: sib = SageInputBuilder()\n sage: sib.assign(sib.name('foo').x, sib.name('pi'))\n {assign: {getattr: {atomic...
class SageInputFormatter(): '\n An instance of this class is used to keep track of variable names\n and a sequence of generated commands during the :func:`sage_input`\n formatting process.\n ' def __init__(self): '\n Initialize an instance of :class:`SageInputFormatter`.\n\n ...
def verify_same(a, b): "\n Verify that two Sage values are the same. This is an extended equality\n test; it checks that the values are equal and that their parents are equal.\n (For values which are not Elements, the types are checked instead.)\n\n If the values are the same, we return ``None``; oth...
def verify_si_answer(x, answer, preparse): "\n Verify that evaluating ``answer`` gives a value equal to ``x``\n (with the same parent/type). If ``preparse`` is ``True`` or\n ``False``, then we evaluate ``answer`` with the preparser\n enabled or disabled, respectively; if ``preparse`` is ``None``,\n ...
class SageInputAnswer(tuple): "\n This class inherits from tuple, so it acts like a tuple when passed\n to :func:`sage_eval`; but it prints as a sequence of commands.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_input import SageInputAnswer\n sage: v = SageInputAnswer('x = 22\\n', 'x/7'); v...
class SageTimeitResult(): '\n Represent the statistics of a timeit() command.\n\n Prints as a string so that it can be easily returned to a user.\n\n INPUT:\n\n - ``stats`` -- tuple of length 5 containing the following information:\n\n - integer, number of loops\n - integer, repeat numbe...
def sage_timeit(stmt, globals_dict=None, preparse=None, number=0, repeat=3, precision=3, seconds=False): 'nodetex\n Accurately measure the wall time required to execute ``stmt``.\n\n INPUT:\n\n - ``stmt`` -- a text string.\n\n - ``globals_dict`` -- a dictionary or ``None`` (default). Evaluate\n `...
class TestSuite(): "\n Test suites for Sage objects.\n\n EXAMPLES::\n\n sage: TestSuite(ZZ).run()\n\n No output means that all tests passed. Which tests?\n In practice this calls all the methods ``._test_*`` of this\n object, in alphabetic order::\n\n sage: TestSuite(1).run(verbose = ...
class TestSuiteFailure(AssertionError): pass
def instance_tester(instance, tester=None, **options): '\n Return a gadget attached to ``instance`` providing testing utilities.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_unittest import instance_tester\n sage: tester = instance_tester(ZZ)\n\n sage: tester.assertTrue(1 == 1)\n ...
class InstanceTester(unittest.TestCase): '\n A gadget attached to an instance providing it with testing utilities.\n\n EXAMPLES::\n\n sage: from sage.misc.sage_unittest import InstanceTester\n sage: InstanceTester(instance = ZZ, verbose = True, elements = [1,2,3])\n Testing utilities fo...
class PythonObjectWithTests(): '\n Utility class for running basis tests on a plain Python object\n (that is not in SageObject). More test methods can be added here.\n\n EXAMPLES::\n\n sage: TestSuite("bla").run()\n ' def __init__(self, instance): '\n EXAMPLES::\n\n ...
def _rmcmd(s, cmd, left='', right=''): "\n Remove the LaTeX command ``cmd`` from the string ``s``. This\n function is used by ``detex``.\n\n INPUT:\n\n - ``s`` - (string) string from which to remove the command\n\n - ``cmd`` - (string) command to be removed. This should be a\n command which ...
def detex(s, embedded=False): "nodetex\n This strips LaTeX commands from a string; it is used by the\n ``format`` function to process docstrings for display from the\n command line interface.\n\n INPUT:\n\n - ``s`` - string\n - ``embedded`` - boolean (optional, default False)\n\n If ``embedde...
def skip_TESTS_block(docstring): '\n Remove blocks labeled "TESTS:" from ``docstring``.\n\n INPUT:\n\n - ``docstring``, a string\n\n A "TESTS" block is a block starting "TESTS:" (or\n the same with two colons), on a line on its own, and ending either\n with a line indented less than "TESTS", or ...
def process_dollars(s): 'nodetex\n Replace dollar signs with backticks.\n\n More precisely, do a regular expression search. Replace a plain\n dollar sign ($) by a backtick (`). Replace an escaped dollar sign\n (\\\\$) by a dollar sign ($). Don\'t change a dollar sign preceded or\n followed by a ...
def process_extlinks(s, embedded=False): "nodetex\n\n In docstrings at the command line, process markup related to the\n Sphinx extlinks extension. For example, replace ``:issue:`NUM```\n with ``https://github.com/sagemath/sage/issues/NUM``, and similarly with\n ``:python:TEXT`` and ``:wikipedia:TEXT`...
def process_mathtt(s): "nodetex\n Replace \\\\mathtt{BLAH} with BLAH in the command line.\n\n INPUT:\n\n - ``s`` - string, in practice a docstring\n\n This function is called by :func:`format`.\n\n EXAMPLES::\n\n sage: from sage.misc.sagedoc import process_mathtt\n sage: process_matht...
def process_optional_doctest_tags(s): '\n Remove ``# optional/needs`` doctest tags for present features from docstring ``s``.\n\n EXAMPLES:\n\n sage: from sage.misc.sagedoc import process_optional_doctest_tags\n sage: process_optional_doctest_tags("sage: # needs sage.rings.finite_rings\\nsage:...
def format(s, embedded=False): 'noreplace\n Format Sage documentation ``s`` for viewing with IPython.\n\n This calls ``detex`` on ``s`` to convert LaTeX commands to plain\n text, unless the directive ``nodetex`` is given in the first line\n of the string.\n\n Also, if ``s`` contains a string of the...
def format_src(s): '\n Format Sage source code ``s`` for viewing with IPython.\n\n If ``s`` contains a string of the form "<<<obj>>>", then it\n replaces it with the source code for "obj".\n\n INPUT: ``s`` - string\n\n OUTPUT: string\n\n EXAMPLES::\n\n sage: from sage.misc.sagedoc import ...
def _search_src_or_doc(what, string, extra1='', extra2='', extra3='', extra4='', extra5='', **kwargs): '\n Search the Sage library or documentation for lines containing\n ``string`` and possibly some other terms. This function is used by\n :func:`search_src`, :func:`search_doc`, and :func:`search_def`.\n...
def search_src(string, extra1='', extra2='', extra3='', extra4='', extra5='', **kwds): '\n Search Sage library source code for lines containing ``string``.\n The search is case-insensitive by default.\n\n INPUT:\n\n - ``string`` - a string to find in the Sage source code.\n\n - ``extra1``, ..., ``e...
def search_doc(string, extra1='', extra2='', extra3='', extra4='', extra5='', **kwds): "\n Search Sage HTML documentation for lines containing ``string``. The\n search is case-insensitive by default.\n\n The file paths in the output are relative to ``$SAGE_DOC``.\n\n INPUT: same as for :func:`search_s...
def search_def(name, extra1='', extra2='', extra3='', extra4='', extra5='', **kwds): '\n Search Sage library source code for function definitions containing\n ``name``. The search is case-insensitive by default.\n\n INPUT: same as for :func:`search_src`.\n\n OUTPUT: same as for :func:`search_src`.\n\n...
def format_search_as_html(what, results, search): '\n Format the output from ``search_src``, ``search_def``, or\n ``search_doc`` as html, for use in the notebook.\n\n INPUT:\n\n - ``what`` - (string) what was searched (source code or\n documentation)\n - ``results`` - (string or list) the resu...
def my_getsource(obj, oname=''): "\n Retrieve the source code for ``obj``.\n\n INPUT:\n\n - ``obj`` -- a Sage object, function, etc.\n\n - ``oname`` -- str (optional). A name under which the object is\n known. Currently ignored by Sage.\n\n OUTPUT:\n\n Its documentation (string)\n\n EXAM...
class _sage_doc(): '\n Open Sage documentation in a web browser, from either the\n command-line or the notebook.\n\n - Type "browse_sage_doc.DOCUMENT()" to open the named document --\n for example, "browse_sage_doc.tutorial()" opens the tutorial.\n Available documents are\n\n - tutorial: t...
def help(module=None): '\n If there is an argument ``module``, print the Python help message\n for ``module``. With no argument, print a help message about\n getting help in Sage.\n\n EXAMPLES::\n\n sage: help()\n Welcome to Sage ...\n ' if (module is not None): python_he...
def process_docstring_aliases(app, what, name, obj, options, docstringlines): '\n Change the docstrings for aliases to point to the original object.\n ' basename = name.rpartition('.')[2] if (hasattr(obj, '__name__') and (obj.__name__ != basename)): docstringlines[:] = [('See :obj:`%s`.' % n...
def process_directives(app, what, name, obj, options, docstringlines): "\n Remove 'nodetex' and other directives from the first line of any\n docstring where they appear.\n " if (len(docstringlines) == 0): return first_line = docstringlines[0] directives = [d.lower() for d in first_li...
def process_docstring_cython(app, what, name, obj, options, docstringlines): "\n Remove Cython's filename and location embedding.\n " if (len(docstringlines) <= 1): return first_line = docstringlines[0] if (first_line.startswith('File:') and ('(starting at' in first_line)): docst...
def process_docstring_module_title(app, what, name, obj, options, docstringlines): "\n Removes the first line from the beginning of the module's docstring. This\n corresponds to the title of the module's documentation page.\n " if (what != 'module'): return title_removed = False whil...
def process_dollars(app, what, name, obj, options, docstringlines): '\n Replace dollar signs with backticks.\n\n See sage.misc.sagedoc.process_dollars for more information.\n ' if (len(docstringlines) and (name.find('process_dollars') == (- 1))): from sage.misc.sagedoc import process_dollars ...
def process_inherited(app, what, name, obj, options, docstringlines): "\n If we're including inherited members, omit their docstrings.\n " if (not options.get('inherited-members')): return if (what in ['class', 'data', 'exception', 'function', 'module']): return name = name.split...
def skip_TESTS_block(app, what, name, obj, options, docstringlines): '\n Skip blocks labeled "TESTS:".\n\n See sage.misc.sagedoc.skip_TESTS_block for more information.\n ' from sage.misc.sagedoc import skip_TESTS_block as sagedoc_skip_TESTS if (not docstringlines): return s = sagedoc_...
class SagemathTransform(Transform): '\n Transform for code-blocks.\n\n This allows Sphinx to treat code-blocks with prompt "sage:" as\n associated with the pycon lexer, and in particular, to change\n "<BLANKLINE>" to a blank line.\n ' default_priority = 500 def apply(self): for nod...
def setup(app): app.connect('autodoc-process-docstring', process_docstring_cython) app.connect('autodoc-process-docstring', process_directives) app.connect('autodoc-process-docstring', process_docstring_module_title) app.connect('autodoc-process-docstring', process_dollars) app.connect('autodoc-pr...
def is_function_or_cython_function(obj): '\n Check whether something is a function.\n\n This is a variant of :func:`inspect.isfunction`:\n We assume that anything which has a genuine ``__code__``\n attribute (not using ``__getattr__`` overrides) is a function.\n This is meant to support Cython func...
def loadable_module_extension(): '\n Return the filename extension of loadable modules, including the dot.\n\n This function is deprecated.\n\n EXAMPLES::\n\n sage: from sage.misc.sageinspect import loadable_module_extension\n sage: from importlib.machinery import EXTENSION_SUFFIXES\n ...
def isclassinstance(obj): '\n Check if argument is instance of non built-in class\n\n INPUT: ``obj`` -- object\n\n EXAMPLES::\n\n sage: from sage.misc.sageinspect import isclassinstance\n sage: isclassinstance(int)\n False\n sage: class myclass: pass\n sage: isclassinst...
def _extract_embedded_position(docstring): "\n If docstring has a Cython embedded position, return a tuple\n (original_docstring, filename, line). If not, return None.\n\n INPUT: ``docstring`` (string)\n\n EXAMPLES::\n\n sage: from sage.misc.sageinspect import _extract_embedded_position\n ...
def _extract_embedded_signature(docstring, name): "\n If docstring starts with the embedded of a method called ``name``, return\n a tuple (original_docstring, argspec). If not, return (docstring, None).\n\n See :trac:`17814`.\n\n INPUT: ``docstring`` (string)\n\n AUTHORS:\n\n - Simon King\n\n ...
class BlockFinder(): "\n Provide a tokeneater() method to detect the end of a code block.\n\n This is the Python library's :class:`inspect.BlockFinder` modified\n to recognize Cython definitions.\n " def __init__(self): self.indent = 0 self.islambda = False self.started = ...
def _getblock(lines): "\n Extract the block of code at the top of the given list of lines.\n\n This is the Python library's :func:`inspect.getblock`, except that\n it uses an instance of our custom :class:`BlockFinder`.\n " blockfinder = BlockFinder() iter_lines = iter(lines) tokenizer = t...
def _extract_source(lines, lineno): '\n Given a list of lines or a multiline string and a starting lineno,\n _extract_source returns [source_lines]. [source_lines] is the smallest\n indentation block starting at lineno.\n\n INPUT:\n\n - ``lines`` - string or list of strings\n - ``lineno`` - pos...
class SageArgSpecVisitor(ast.NodeVisitor): '\n A simple visitor class that walks an abstract-syntax tree (AST)\n for a Python function\'s argspec. It returns the contents of nodes\n representing the basic Python types: None, booleans, numbers,\n strings, lists, tuples, and dictionaries. We use this ...
def _grep_first_pair_of_parentheses(s): '\n Return the first matching pair of parentheses in a code string.\n\n INPUT:\n\n A string\n\n OUTPUT:\n\n A substring of the input, namely the part between the first\n (outmost) matching pair of parentheses (including the\n parentheses).\n\n Parent...
def _split_syntactical_unit(s): '\n Split off a sub-expression from the start of a given string.\n\n INPUT:\n\n - ``s``, a string\n\n OUTPUT:\n\n A pair ``unit, s2``, such that ``unit`` is the string representation of a\n string (single or double quoted) or of a sub-expression surrounded by\n ...
def _sage_getargspec_from_ast(source): '\n Return an argspec for a Python function or method by compiling its\n source to an abstract-syntax tree (AST) and walking its ``args``\n subtrees with :class:`SageArgSpecVisitor`. We use this in\n :func:`_sage_getargspec_cython`.\n\n INPUT:\n\n - ``sour...
def _sage_getargspec_cython(source): '\n inspect.getargspec from source code. That is, get the names and\n default values of a function\'s arguments.\n\n INPUT:\n\n - ``source`` - a string; the function\'s (or method\'s) source code\n definition. The function\'s body is ignored. The definition ...
def sage_getfile(obj): "\n Get the full file name associated to ``obj`` as a string.\n\n INPUT: ``obj``, a Sage object, module, etc.\n\n EXAMPLES::\n\n sage: from sage.misc.sageinspect import sage_getfile\n sage: sage_getfile(sage.rings.rational)\n '...sage/rings/rational.pyx'\n ...
def sage_getfile_relative(obj): "\n Get the file name associated to ``obj`` as a string.\n\n This is the same as :func:`sage_getfile`, but\n if the source file is part of the ``sage.*`` namespace, it\n makes the file name relative so that it starts with ``sage/``.\n\n INPUT: ``obj``, a Sage object,...
def sage_getargspec(obj): '\n Return the names and default values of a function\'s arguments.\n\n INPUT:\n\n - ``obj`` -- any callable object\n\n OUTPUT:\n\n A named tuple :class:`FullArgSpec` is returned, as specified by the\n Python library function :func:`inspect.getfullargspec`.\n\n NOTE:...
def formatannotation(annotation, base_module=None): "\n This is taken from Python 3.7's inspect.py; the only change is to\n add documentation.\n\n INPUT:\n\n - ``annotation`` -- annotation for a function\n - ``base_module`` (optional, default ``None``)\n\n This is only relevant with Python 3, so...
def sage_formatargspec(args, varargs=None, varkw=None, defaults=None, kwonlyargs=(), kwonlydefaults=None, annotations={}, formatarg=str, formatvarargs=None, formatvarkw=None, formatvalue=None, formatreturns=None, formatannotation=None): "\n Format an argument spec from the values returned by getfullargspec.\n\...
def sage_getdef(obj, obj_name=''): "\n Return the definition header for any callable object.\n\n INPUT:\n\n - ``obj`` - function\n - ``obj_name`` - string (optional, default '')\n\n ``obj_name`` is prepended to the output.\n\n EXAMPLES::\n\n sage: from sage.misc.sageinspect import sage_ge...
def _sage_getdoc_unformatted(obj): '\n Return the unformatted docstring associated to ``obj`` as a\n string.\n\n If ``obj`` is a Cython object with an embedded position in its\n docstring, the embedded position is **not** stripped.\n\n INPUT:\n\n - ``obj`` -- a function, module, etc.: something ...
def sage_getdoc_original(obj): "\n Return the unformatted docstring associated to ``obj`` as a\n string.\n\n If ``obj`` is a Cython object with an embedded position or signature in\n its docstring, the embedded information is stripped. If the stripped\n docstring is empty, then the stripped docstri...
def sage_getdoc(obj, obj_name='', embedded=False): '\n Return the docstring associated to ``obj`` as a string.\n\n If ``obj`` is a Cython object with an embedded position in its\n docstring, the embedded position is stripped.\n\n The optional boolean argument ``embedded`` controls the\n string form...
def sage_getsource(obj): "\n Return the source code associated to obj as a string, or None.\n\n INPUT:\n\n - ``obj`` -- function, etc.\n\n EXAMPLES::\n\n sage: from sage.misc.sageinspect import sage_getsource\n sage: sage_getsource(identity_matrix)[19:60] ...
def _sage_getsourcelines_name_with_dot(obj): '\n Get the source lines of an object whose name\n contains a dot and whose source lines can not\n be obtained by different methods.\n\n EXAMPLES::\n\n sage: C = Rings()\n sage: from sage.misc.sageinspect import sage_getsource\n sage: p...
def sage_getsourcelines(obj): '\n Return a pair ([source_lines], starting line number) of the source\n code associated to obj, or None.\n\n INPUT:\n\n - ``obj`` -- function, etc.\n\n OUTPUT:\n\n (source_lines, lineno) or None: ``source_lines`` is a list of\n strings, and ``lineno`` is an inte...
def sage_getvariablename(self, omit_underscore_names=True): '\n Attempt to get the name of a Sage object.\n\n INPUT:\n\n - ``self`` -- any object.\n\n - ``omit_underscore_names`` -- boolean, default ``True``.\n\n OUTPUT:\n\n If the user has assigned an object ``obj`` to a variable name,\n the...
def __internal_tests(): '\n Test internals of the sageinspect module.\n\n EXAMPLES::\n\n sage: from sage.misc.sageinspect import *\n sage: from sage.misc.sageinspect import _extract_source, _extract_embedded_position, _sage_getargspec_cython, __internal_teststring\n\n If docstring is None, ...
class Sh(): '\n Evaluates a shell script and returns the output.\n\n To use this from the notebook type ``sh`` at the beginning of\n the input cell. The working directory is then the (usually\n temporary) directory where the Sage worksheet process is\n executing.\n ' def eval(self, code, g...
def sphinxify(docstring, format='html'): '\n Runs Sphinx on a ``docstring``, and outputs the processed\n documentation.\n\n INPUT:\n\n - ``docstring`` -- string -- a ReST-formatted docstring\n\n - ``format`` -- string (optional, default \'html\') -- either \'html\' or\n \'text\'\n\n OUTPUT:...