code stringlengths 17 6.64M |
|---|
def addlp(M, M1, L, P, ptsdict, G=None, limits=None):
'\n Return a graphics object containing loops (in inset) and parallel elements\n of matroid.\n\n INPUT:\n\n - ``M`` -- A matroid.\n - ``M1`` -- A simple matroid corresponding to ``M``.\n - ``L`` -- List of elements in ``M.groundset()`` that a... |
def line_hasorder(l, lodrs=None):
"\n Determine if an order is specified for a line\n\n INPUT:\n\n - ``l`` -- A line specified as a list of ground set elements.\n - ``lordrs`` -- (optional) A list of lists each specifying an order on\n a subset of ground set elements that may or may not correspon... |
def lineorders_union(lineorders1, lineorders2):
"\n Return a list of ordered lists of ground set elements that corresponds to\n union of two sets of ordered lists of ground set elements in a sense.\n\n INPUT:\n\n - ``lineorders1`` -- A list of ordered lists specifying orders on subsets\n of groun... |
def posdict_is_sane(M1, pos_dict):
'\n Return a boolean establishing sanity of ``posdict`` wrt matroid ``M``.\n\n INPUT:\n\n - ``M1`` -- A matroid.\n - ``posdict`` -- A dictionary mapping ground set elements to (x,y)\n positions.\n\n OUTPUT:\n\n A boolean that is ``True`` if posdict indeed ... |
def tracklims(lims, x_i=[], y_i=[]):
'\n Return modified limits list.\n\n INPUT:\n\n - ``lims`` -- A list with 4 elements ``[xmin,xmax,ymin,ymax]``\n - ``x_i`` -- New x values to track\n - ``y_i`` -- New y values to track\n\n OUTPUT:\n\n A list with 4 elements ``[xmin,xmax,ymin,ymax]``\n\n ... |
def geomrep(M1, B1=None, lineorders1=None, pd=None, sp=False):
"\n Return a sage graphics object containing geometric representation of\n matroid M1.\n\n INPUT:\n\n - ``M1`` -- A matroid.\n - ``B1`` -- (optional) A list of elements in ``M1.groundset()`` that\n correspond to a basis of ``M1`` a... |
class MinorMatroid(Matroid):
"\n Minor of a matroid.\n\n For some matroid representations, it can be computationally\n expensive to derive an explicit representation of a minor. This\n class wraps around any matroid to provide an abstract minor. It\n also serves as default implementation.\n\n Re... |
class RankMatroid(Matroid):
'\n Matroid specified by its rank function.\n\n INPUT:\n\n - ``groundset`` -- the groundset of a matroid.\n - ``rank_function`` -- a function mapping subsets of ``groundset`` to\n nonnegative integers.\n\n OUTPUT:\n\n A matroid on ``groundset`` whose rank functio... |
def setprint(X):
"\n Print nested data structures nicely.\n\n Python's data structures ``set`` and ``frozenset`` do not print nicely.\n This function can be used as replacement for ``print`` to overcome this.\n For direct access to ``setprint``, run::\n\n sage: from sage.matroids.advanced impor... |
def setprint_s(X, toplevel=False):
'\n Create the string for use by ``setprint()``.\n\n INPUT:\n\n - ``X`` -- any Python object\n - ``toplevel`` -- (default: ``False``) indicates whether this is a\n recursion or not.\n\n OUTPUT:\n\n A string representation of the object, with nice notation ... |
def newlabel(groundset):
"\n Create a new element label different from the labels in ``groundset``.\n\n INPUT:\n\n - ``groundset`` -- A set of objects.\n\n OUTPUT:\n\n A string not in the set ``groundset``.\n\n For direct access to ``newlabel``, run::\n\n sage: from sage.matroids.advanced... |
def sanitize_contractions_deletions(matroid, contractions, deletions):
"\n Return a fixed version of sets ``contractions`` and ``deletions``.\n\n INPUT:\n\n - ``matroid`` -- a :class:`Matroid <sage.matroids.matroid.Matroid>`\n instance.\n - ``contractions`` -- a subset of the groundset.\n - ``... |
def make_regular_matroid_from_matroid(matroid):
'\n Attempt to construct a regular representation of a matroid.\n\n INPUT:\n\n - ``matroid`` -- a matroid.\n\n OUTPUT:\n\n Return a `(0, 1, -1)`-matrix over the integers such that, if the input is\n a regular matroid, then the output is a totally u... |
def get_nonisomorphic_matroids(MSet):
'\n Return non-isomorphic members of the matroids in set ``MSet``.\n\n For direct access to ``get_nonisomorphic_matroids``, run::\n\n sage: from sage.matroids.advanced import *\n\n INPUT:\n\n - ``MSet`` -- an iterable whose members are matroids.\n\n OUTP... |
def spanning_forest(M):
'\n Return a list of edges of a spanning forest of the bipartite\n graph defined by `M`\n\n INPUT:\n\n - ``M`` -- a matrix defining a bipartite graph G. The vertices are the\n rows and columns, if `M[i,j]` is non-zero, then there is an edge\n between row `i` and colum... |
def spanning_stars(M):
'\n Return the edges of a connected subgraph that is a union of\n all edges incident some subset of vertices.\n\n INPUT:\n\n - ``M`` -- a matrix defining a bipartite graph G. The vertices are the\n rows and columns, if `M[i,j]` is non-zero, then there is an edge\n betw... |
def lift_cross_ratios(A, lift_map=None):
"\n Return a matrix which arises from the given matrix by lifting cross ratios.\n\n INPUT:\n\n - ``A`` -- a matrix over a ring ``source_ring``.\n - ``lift_map`` -- a python dictionary, mapping each cross ratio of ``A`` to some element\n of a target ring, a... |
def lift_map(target):
'\n Create a lift map, to be used for lifting the cross ratios of a matroid\n representation.\n\n .. SEEALSO::\n\n :meth:`lift_cross_ratios() <sage.matroids.utilities.lift_cross_ratios>`\n\n INPUT:\n\n - ``target`` -- a string describing the target (partial) field.\n\n ... |
def split_vertex(G, u, v=None, edges=None):
'\n Split a vertex in a graph.\n\n If an edge is inserted between the vertices after splitting, this\n corresponds to a graphic coextension of a matroid.\n\n INPUT:\n\n - ``G`` -- A SageMath :class:`Graph`.\n - ``u`` -- A vertex in ``G``.\n - ``v`` ... |
def abstract_method(f=None, optional=False):
'\n Abstract methods\n\n INPUT:\n\n - ``f`` -- a function\n - ``optional`` -- a boolean; defaults to ``False``\n\n The decorator :obj:`abstract_method` can be used to declare\n methods that should be implemented by all concrete derived\n classes.... |
class AbstractMethod():
def __init__(self, f, optional=False):
'\n Constructor for abstract methods\n\n EXAMPLES::\n\n sage: def f(x):\n ....: "doc of f"\n ....: return 1\n sage: x = abstract_method(f); x\n <abstract method f at... |
def abstract_methods_of_class(cls):
"\n Returns the required and optional abstract methods of the class\n\n EXAMPLES::\n\n sage: class AbstractClass:\n ....: @abstract_method\n ....: def required1(): pass\n ....:\n ....: @abstract_method(optional = True)\n ... |
def version():
"\n Return the version of Sage.\n\n OUTPUT:\n\n str\n\n EXAMPLES::\n\n sage: version()\n 'SageMath version ..., Release Date: ...'\n "
return SAGE_VERSION_BANNER
|
def banner_text(full=True):
'\n Text for the Sage banner.\n\n INPUT:\n\n - ``full`` -- boolean (optional, default=``True``)\n\n OUTPUT:\n\n A string containing the banner message.\n\n If option full is ``False``, a simplified plain ASCII banner is\n displayed; if ``True`` the full banner with... |
def banner():
'\n Print the Sage banner.\n\n OUTPUT: None\n\n If the environment variable ``SAGE_BANNER`` is set to ``no``, no\n banner is displayed. If ``SAGE_BANNER`` is set to ``bare``, a\n simplified plain ASCII banner is displayed. Otherwise, the full\n banner with box art is displayed.\n\n... |
def version_dict():
'\n A dictionary describing the version of Sage.\n\n INPUT:\n\n nothing\n\n OUTPUT:\n\n dictionary with keys \'major\', \'minor\', \'tiny\', \'prerelease\'\n\n This process the Sage version string and produces a dictionary.\n It expects the Sage version to be in one of the... |
def require_version(major, minor=0, tiny=0, prerelease=False, print_message=False):
'\n True if Sage version is at least major.minor.tiny.\n\n INPUT:\n\n - major -- integer\n - minor -- integer (optional, default = 0)\n - tiny -- float (optional, default = 0)\n - prerelease -- boolean (optional,... |
def benchmark(n=(- 1)):
"\n Run a well-chosen range of Sage commands and record the time it\n takes for each to run.\n\n INPUT:\n\n n -- int (default: -1) the benchmark number; the default\n of -1 runs all the benchmarks.\n\n OUTPUT:\n\n list -- summary of timings for each be... |
def bench0():
'\n Run a benchmark.\n\n BENCHMARK::\n\n sage: from sage.misc.benchmark import *\n sage: print(bench0()[0])\n Benchmark 0: Factor the following polynomial over\n the rational numbers: (x^97+19*x+1)*(x^103-19*x^97+14)*(x^100-1)\n\n '
desc = 'Benchmark 0: F... |
def bench1():
'\n Run a benchmark.\n\n BENCHMARK::\n\n sage: from sage.misc.benchmark import *\n sage: print(bench1()[0])\n Find the Mordell-Weil group of the elliptic curve 5077A using mwrank\n\n '
desc = 'Find the Mordell-Weil group of the elliptic curve 5077A using mwrank'
... |
def bench2():
"\n Run a benchmark.\n\n BENCHMARK::\n\n sage: from sage.misc.benchmark import *\n sage: print(bench2()[0])\n Some basic arithmetic with very large Integer numbers: '3^1000001 * 19^100001\n\n "
desc = "Some basic arithmetic with very large Integer numbers: '3^100000... |
def bench3():
"\n Run a benchmark.\n\n BENCHMARK::\n\n sage: from sage.misc.benchmark import *\n sage: print(bench3()[0])\n Some basic arithmetic with very large Rational numbers: '(2/3)^100001 * (17/19)^100001\n\n "
desc = "Some basic arithmetic with very large Rational numbers:... |
def bench4():
'\n Run a benchmark.\n\n BENCHMARK::\n\n sage: from sage.misc.benchmark import *\n sage: print(bench4()[0])\n Rational polynomial arithmetic using Sage. Compute (x^29+17*x-5)^200.\n\n '
desc = 'Rational polynomial arithmetic using Sage. Compute (x^29+17*x-5)^200.'
... |
def bench5():
'\n Run a benchmark.\n\n BENCHMARK::\n\n sage: from sage.misc.benchmark import *\n sage: print(bench5()[0])\n Rational polynomial arithmetic using Sage. Compute (x^19 - 18*x + 1)^50 one hundred times.\n\n '
desc = 'Rational polynomial arithmetic using Sage. Compute ... |
def bench6():
'\n Run a benchmark.\n\n BENCHMARK::\n\n sage: from sage.misc.benchmark import *\n sage: print(bench6()[0])\n Compute the p-division polynomials of y^2 = x^3 + 37*x - 997 for primes p < 40.\n\n '
desc = 'Compute the p-division polynomials of y^2 = x^3 + 37*x - 997 f... |
def bench7():
'\n Run a benchmark.\n\n BENCHMARK::\n\n sage: from sage.misc.benchmark import *\n sage: print(bench7()[0])\n Compute the Mordell-Weil group of y^2 = x^3 + 37*x - 997.\n\n '
desc = 'Compute the Mordell-Weil group of y^2 = x^3 + 37*x - 997.'
E = EllipticCurve([0,... |
class BindableClass(metaclass=ClasscallMetaclass):
'\n Bindable classes\n\n This class implements a binding behavior for nested classes that\n derive from it. Namely, if a nested class ``Outer.Inner`` derives\n from ``BindableClass``, and if ``outer`` is an instance of\n ``Outer``, then ``outer.Inn... |
class BoundClass(functools.partial):
"\n TESTS::\n\n sage: from sage.misc.sageinspect import *\n sage: from sage.misc.bindable_class import Outer\n sage: x = Outer()\n sage: c = x.Inner; c\n <bound class 'sage.misc.bindable_class.Outer.Inner' of <sage.misc.bindable_class.Oute... |
class Inner2(BindableClass):
'\n Some documentation for Inner2\n '
|
class Outer(metaclass=NestedClassMetaclass):
'\n A class with a bindable nested class, for testing purposes\n '
class Inner(BindableClass):
'\n Some documentation for Outer.Inner\n '
Inner2 = Inner2
|
class AttrCallObject():
def __init__(self, name, args, kwds):
"\n TESTS::\n\n sage: f = attrcall('core', 3); f\n *.core(3)\n sage: TestSuite(f).run()\n "
self.name = name
self.args = args
self.kwds = kwds
def __call__(self, x, *a... |
def attrcall(name, *args, **kwds):
"\n Return a callable which takes in an object, gets the method named\n name from that object, and calls it with the specified arguments\n and keywords.\n\n INPUT:\n\n - ``name`` - a string of the name of the method you\n want to call\n\n - ``args, kwds... |
def call_method(obj, name, *args, **kwds):
'\n Call the method ``name`` on ``obj``.\n\n This has to exist somewhere in Python!!!\n\n .. SEEALSO:: :func:`operator.methodcaller` :func:`attrcal`\n\n EXAMPLES::\n\n sage: from sage.misc.call import call_method\n sage: call_method(1, "__add__"... |
def class_graph(top, depth=5, name_filter=None, classes=None, as_graph=True):
"\n Return the class inheritance graph of a module, class, or object\n\n INPUT:\n\n - ``top`` -- the module, class, or object to start with (e.g. ``sage``, ``Integer``, ``3``)\n - ``depth`` -- maximal recursion depth withi... |
def find_library(name):
'\n Returns the shared library filename for a given library.\n\n The library name is given without any prefixes or suffixes--(e.g.\n just "Singular", not "libSingular", as shared library naming is\n platform-specific.\n\n This does \'\'not\'\' currently return the absolute p... |
class KeyConvertingDict(dict):
'\n A dictionary which automatically applies a conversions to its keys.\n\n The most common application is the case where the conversion\n function is the object representing some category, so that key\n conversion means a type conversion to adapt keys to that\n categ... |
class License():
def __call__(self):
pager.pager()(str(self))
def __repr__(self):
return 'Type license() to see the full license text.'
def __str__(self):
with open(os.path.join(SAGE_ROOT, 'COPYING.txt')) as f:
return f.read()
|
@cached_function
def _standard_libs_libdirs_incdirs_aliases():
"\n Return the list of libraries and library directories.\n\n EXAMPLES::\n\n sage: from sage.misc.cython import _standard_libs_libdirs_incdirs_aliases\n sage: _standard_libs_libdirs_incdirs_aliases()\n (['mpfr', 'gmp', 'gmpx... |
def cython(filename, verbose=0, compile_message=False, use_cache=False, create_local_c_file=False, annotate=True, sage_namespace=True, create_local_so_file=False):
'\n Compile a Cython file. This converts a Cython file to a C (or C++ file),\n and then compiles that. The .c file and the .so file are\n cre... |
def cython_lambda(vars, expr, verbose=0, **kwds):
"\n Create a compiled function which evaluates ``expr`` assuming machine values\n for ``vars``.\n\n INPUT:\n\n - ``vars`` - list of pairs (variable name, c-data type), where the variable\n names and data types are strings, OR a string such as ``'d... |
def cython_import(filename, **kwds):
'\n Compile a file containing Cython code, then import and return the\n module. Raises an ``ImportError`` if anything goes wrong.\n\n INPUT:\n\n - ``filename`` - a string; name of a file that contains Cython\n code\n\n See the function :func:`sage.misc.cyt... |
def cython_import_all(filename, globals, **kwds):
'\n Imports all non-private (i.e., not beginning with an underscore)\n attributes of the specified Cython module into the given context.\n This is similar to::\n\n from module import *\n\n Raises an ``ImportError`` exception if anything goes wro... |
def sanitize(f):
"\n Given a filename ``f``, replace it by a filename that is a valid Python\n module name.\n\n This means that the characters are all alphanumeric or ``_``'s and doesn't\n begin with a numeral.\n\n EXAMPLES::\n\n sage: from sage.misc.cython import sanitize\n sage: san... |
def compile_and_load(code, **kwds):
'\n INPUT:\n\n - ``code`` -- string containing code that could be in a .pyx file\n that is attached or put in a %cython block in the notebook.\n\n OUTPUT: a module, which results from compiling the given code and\n importing it\n\n EXAMPLES::\n\n sage... |
def cython_compile(code, **kwds):
"\n Given a block of Cython code (as a text string), this function\n compiles it using a C compiler, and includes it into the global\n namespace.\n\n AUTHOR: William Stein, 2006-10-31\n\n .. WARNING::\n\n Only use this from Python code, not from extension co... |
def sage_wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES):
'\n Decorator factory which should be used in decorators for making sure that\n meta-information on the decorated callables are retained through the\n decorator, such that the introspection functions of\n ``sage.misc.sagei... |
class infix_operator():
"\n A decorator for functions which allows for a hack that makes\n the function behave like an infix operator.\n\n This decorator exists as a convenience for interactive use.\n\n EXAMPLES:\n\n An infix dot product operator::\n\n sage: @infix_operator('multiply')\n ... |
class _infix_wrapper():
function = None
def __init__(self, left=None, right=None):
'\n Initialize the actual infix object, with possibly a specified left\n and/or right operand.\n '
self.left = left
self.right = right
def __call__(self, *args, **kwds):
... |
def decorator_defaults(func):
"\n This function allows a decorator to have default arguments.\n\n Normally, a decorator can be called with or without arguments.\n However, the two cases call for different types of return values.\n If a decorator is called with no parentheses, it should be run\n dir... |
class suboptions():
def __init__(self, name, **options):
"\n A decorator for functions which collects all keywords\n starting with ``name+'_'`` and collects them into a dictionary\n which will be passed on to the wrapped function as a\n dictionary called ``name_options``.\n\n ... |
class options():
def __init__(self, **options):
'\n A decorator for functions which allows for default options to be\n set and reset by the end user. Additionally, if one needs to, one\n can get at the original keyword arguments passed into the\n decorator.\n\n TESTS::... |
class rename_keyword():
def __init__(self, deprecated=None, deprecation=None, **renames):
"\n A decorator which renames keyword arguments and optionally\n deprecates the new keyword.\n\n INPUT:\n\n - ``deprecation`` -- integer. The github issue number where the\n depr... |
class specialize():
'\n A decorator generator that returns a decorator that in turn\n returns a specialized function for function ``f``. In other words,\n it returns a function that acts like ``f`` with arguments\n ``*args`` and ``**kwargs`` supplied.\n\n INPUT:\n\n - ``*args``, ``**kwargs`` -- ... |
def decorator_keywords(func):
'\n A decorator for decorators with optional keyword arguments.\n\n EXAMPLES::\n\n sage: from sage.misc.decorators import decorator_keywords\n sage: @decorator_keywords\n ....: def preprocess(f=None, processor=None):\n ....: def wrapper(*args, **... |
def variable_names(n, name=None):
"\n Convert a root string into a tuple of variable names by adding\n numbers in sequence.\n\n INPUT:\n\n - ``n`` a non-negative Integer; the number of variable names to\n output\n - ``names`` a string (default: ``None``); the root of the variable\n name.... |
def latex_variable_names(n, name=None):
"\n Convert a root string into a tuple of variable names by adding\n numbers in sequence.\n\n INPUT:\n\n - ``n`` a non-negative Integer; the number of variable names to\n output\n - ``names`` a string (default: ``None``); the root of the variable\n ... |
def set_default_variable_name(name, separator=''):
'\n Change the default variable name and separator.\n '
global var_name, var_sep
var_name = str(name)
var_sep = str(separator)
|
def series_precision():
'\n Return the Sage-wide precision for series (symbolic,\n power series, Laurent series).\n\n EXAMPLES::\n\n sage: series_precision()\n 20\n '
return series_prec
|
def set_series_precision(prec):
'\n Change the Sage-wide precision for series (symbolic,\n power series, Laurent series).\n\n EXAMPLES::\n\n sage: set_series_precision(5)\n sage: series_precision()\n 5\n sage: set_series_precision(20)\n '
global series_prec
series_p... |
def runsnake(command):
'\n Graphical profiling with ``runsnake``\n\n INPUT:\n\n - ``command`` -- the command to be run as a string.\n\n EXAMPLES::\n\n sage: from sage.misc.dev_tools import runsnake\n sage: runsnake("list(SymmetricGroup(3))") # optional - runsnake\n\n ``command`... |
def import_statement_string(module, names, lazy):
'\n Return a (lazy) import statement for ``names`` from ``module``.\n\n INPUT:\n\n - ``module`` -- the name of a module\n\n - ``names`` -- a list of 2-tuples containing names and alias to\n import\n\n - ``lazy`` -- a boolean: whether to return ... |
def load_submodules(module=None, exclude_pattern=None):
'\n Load all submodules of a given modules.\n\n This method is intended to be used by developers and especially the one\n who uses :func:`import_statements`. By default it load the sage library and\n it takes around a minute.\n\n INPUT:\n\n ... |
def find_objects_from_name(name, module_name=None, include_lazy_imports=False):
"\n Return the list of objects from ``module_name`` whose name is ``name``.\n\n INPUT:\n\n - ``name`` -- string\n\n - ``module_name`` -- string or ``None``:\n\n - If ``module_name`` is ``None``, the function runs thro... |
def find_object_modules(obj):
"\n Return a dictionary whose keys are the names of the modules where ``obj``\n appear and the value at a given module name is the list of names that\n ``obj`` have in that module.\n\n It is very unlikely that the output dictionary has several keys except when\n ``obj`... |
def import_statements(*objects, **kwds):
'\n Print import statements for the given objects.\n\n INPUT:\n\n - ``*objects`` -- a sequence of objects or comma-separated strings of names.\n\n - ``lazy`` -- a boolean (default: ``False``)\n Whether to print a lazy import statement.\n\n - ``verbose``... |
def install_scripts(directory=None, ignore_existing=False):
'\n This function has been deprecated.\n\n Running ``install_scripts(directory)`` creates scripts in the\n given directory that run various software components included with\n Sage. Each of these scripts essentially just runs ``sage --CMD``\... |
def file_and_line(obj):
"\n Look up source file and line number of ``obj``.\n\n If the file lies in the Sage library, the path name of the\n corresponding file in the current branch (i.e., the file that gets\n copied into the Sage library upon running 'sage -br'). Note that\n the first line of a f... |
def template_fields(template):
'\n Given a String.Template object, returns the fields.\n\n AUTHOR:\n\n Nils Bruin (2007-10-22)\n\n EXAMPLES::\n\n sage: from sage.misc.edit_module import template_fields\n sage: from string import Template\n sage: t = Template("Template ${one} with ... |
def set_edit_template(template_string):
'\n Set the default edit template string.\n\n It should reference ``${file}`` and ``${line}``. This routine normally\n needs to be called prior to using \'edit\'. However, if the editor\n set in the shell variable :envvar:`EDITOR` is known, then the system will\... |
def set_editor(editor_name, opts=''):
"\n Set the editor to be used by the edit command by basic editor name.\n\n Currently, the system only knows appropriate call strings for a\n limited number of editors. If you want to use another editor, you\n should set the whole edit template via :func:`set_edit... |
def edit(obj, editor=None, bg=None):
'nodetex\n Open source code of ``obj`` in editor of your choice.\n\n INPUT:\n\n - editor -- str (default: None); If given, use specified editor.\n Choice is stored for next time.\n\n AUTHOR:\n\n Nils Bruin (2007-10-03)\n\n EXAMPLES:\n\n This is a typi... |
def edit_devel(self, filename, linenum):
"\n This function is for internal use and is called by IPython when you use\n the IPython commands ``%edit`` or ``%ed``.\n\n This hook calls the default implementation, but changes the filename for\n files that appear to be from the sage library: if the filenam... |
class ElementWithLabel():
'\n Auxiliary class for showing/viewing :class:`Poset`s with\n non-injective labelings.\n For hashing and equality testing the resulting object behaves\n like a tuple ``(element, label)``.\n For any presentation purposes it appears just as ``label`` would.\n\n EXAMPLES:... |
def explain_pickle(pickle=None, file=None, compress=True, **kwargs):
"\n Explain a pickle. That is, produce source code such that evaluating\n the code is equivalent to loading the pickle. Feeding the result\n of :func:`explain_pickle` to :func:`sage_eval` should be totally equivalent to loading\n th... |
def explain_pickle_string(pickle, in_current_sage=False, default_assumptions=False, eval=False, preparse=True, pedantic=False):
'\n This is a helper function for :func:`explain_pickle`. It takes a decompressed\n pickle string as input; other than that, its options are all the same\n as :func:`explain_pi... |
def name_is_valid(name):
"\n Test whether a string is a valid Python identifier. (We use a\n conservative test, that only allows ASCII identifiers.)\n\n EXAMPLES::\n\n sage: from sage.misc.explain_pickle import name_is_valid\n sage: name_is_valid('fred')\n True\n sage: name_i... |
class PickleObject():
'\n Pickles have a stack-based virtual machine. The :func:`explain_pickle`\n pickle interpreter mostly uses :class:`sage.misc.sage_input.SageInputExpression` objects\n as the stack values. However, sometimes we want some more information\n about the value on the stack, so that ... |
class PickleDict():
'\n An object which can be used as the value of a :class:`PickleObject`. The items\n is a list of key-value pairs, where the keys and values are\n :class:`SageInputExpression` objects. We use this to help construct dictionary literals,\n instead of always starting with an empty d... |
class PickleInstance():
"\n An object which can be used as the value of a :class:`PickleObject`. Unlike\n other possible values of a :class:`PickleObject`, a :class:`PickleInstance` doesn't represent\n an exact value; instead, it gives the class (type) of the object.\n "
def __init__(self, klass... |
class PickleExplainer():
'\n An interpreter for the pickle virtual machine, that executes\n symbolically and constructs :class:`SageInputExpression` objects instead of\n directly constructing values.\n '
def __init__(self, sib, in_current_sage=False, default_assumptions=False, pedantic=False):
... |
def unpickle_newobj(klass, args):
'\n Create a new object; this corresponds to the C code\n ``klass->tp_new(klass, args, NULL)``. Used by :func:`explain_pickle`.\n\n EXAMPLES::\n\n sage: unpickle_newobj(tuple, ([1, 2, 3],))\n (1, 2, 3)\n\n TESTS:\n\n We can create a :class:`Sequence_... |
def unpickle_build(obj, state):
"\n Set the state of an object. Used by :func:`explain_pickle`.\n\n EXAMPLES::\n\n sage: from sage.misc.explain_pickle import *\n sage: v = EmptyNewstyleClass()\n sage: unpickle_build(v, {'hello': 42})\n sage: v.hello\n 42\n "
setsta... |
def unpickle_instantiate(fn, args):
"\n Instantiate a new object of class ``fn`` with arguments ``args``. Almost always\n equivalent to ``fn(*args)``. Used by :func:`explain_pickle`.\n\n EXAMPLES::\n\n sage: unpickle_instantiate(Integer, ('42',))\n 42\n "
if (isinstance(fn, ClassTy... |
def unpickle_persistent(s):
'\n Takes an integer index and returns the persistent object with that\n index; works by calling whatever callable is stored in\n ``unpickle_persistent_loader``. Used by :func:`explain_pickle`.\n\n EXAMPLES::\n\n sage: import sage.misc.explain_pickle\n sage: ... |
def unpickle_extension(code):
"\n Takes an integer index and returns the extension object with that\n index. Used by :func:`explain_pickle`.\n\n EXAMPLES::\n\n sage: from copyreg import *\n sage: add_extension('sage.misc.explain_pickle', 'EmptyNewstyleClass', 42)\n sage: unpickle_ex... |
def unpickle_appends(lst, vals):
'\n Given a list (or list-like object) and a sequence of values, appends the\n values to the end of the list. This is careful to do so using the\n exact same technique that cPickle would use. Used by :func:`explain_pickle`.\n\n EXAMPLES::\n\n sage: v = []\n ... |
def test_pickle(p, verbose_eval=False, pedantic=False, args=()):
"\n Test :func:`explain_pickle` on a given pickle ``p``.\n\n ``p`` can be:\n\n - a string containing an uncompressed pickle (which will always end\n with a '.')\n\n - a string containing a pickle fragment (not ending with '.')\n ... |
class EmptyOldstyleClass():
'\n A featureless old-style class (does not inherit from object); used for\n testing :func:`explain_pickle`.\n '
def __repr__(self):
"\n Print an EmptyOldstyleClass.\n\n EXAMPLES::\n\n sage: from sage.misc.explain_pickle import *\n ... |
class EmptyNewstyleClass():
'\n A featureless new-style class (inherits from object); used for\n testing :func:`explain_pickle`.\n '
def __repr__(self):
"\n Print an EmptyNewstyleClass.\n\n EXAMPLES::\n\n sage: from sage.misc.explain_pickle import *\n sage... |
class TestReduceGetinitargs():
'\n An old-style class with a :func:`__getinitargs__` method. Used for testing\n :func:`explain_pickle`.\n '
def __init__(self):
'\n Initialize a TestReduceGetinitargs object. Note that the\n constructor prints out a message.\n\n EXAMPLES... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.