def init_environment(self): """ Set up Sage command-line environment """ # import outside of cell so we don't get a traceback from sage.repl.user_globals import initialize_globals initialize_globals(self.all_globals(), self.shell.user_ns) self.run_init()
\markboth{\MakeUppercase\indexname}{\MakeUppercase\indexname} \setlength{\parskip}{0.1em} \relax \let\item\@idxitem }{} \makeatother \renewcommand{\ttdefault}{txtt} ''' ##################################################### # add LaTeX macros for Sage from sage.misc.latex_macros import sage_latex_macros try: pngmath_latex_preamble # check whether this is already defined except NameError: pngmath_latex_preamble = "" for macro in sage_latex_macros(): # used when building latex and pdf versions latex_elements['preamble'] += macro + '\n' # used when building html version pngmath_latex_preamble += macro + '\n' ## The following is needed on conda-forge sagemath from sage.repl.user_globals import initialize_globals import sage.all my_globs = dict() initialize_globals(sage.all, my_globs)
import sage # TODO: do we want this? Should this list the features that are being patched? log_level = logging.WARNING # log_level = logging.INFO if log_level <= logging.INFO: print("Loading sage-semigroups and patching its features into Sage's library:") sage_semigroups = sys.modules[__name__] from . import misc, categories, monoids, graphs monkey_patch(sage_semigroups.misc, sage.misc, log_level=log_level) monkey_patch(sage_semigroups.categories, sage.categories, log_level=log_level) monkey_patch(sage_semigroups.graphs, sage.graphs, log_level=log_level) monkey_patch(sage_semigroups.monoids, sage.monoids, log_level=log_level) # Insert the content of sage_semigroups.all in the global name space from . import all from sage.repl.user_globals import initialize_globals initialize_globals(sage_semigroups.all) # Some traces of an attempt # from sage.repl.ipython_extension import SageCustomizations # all = SageCustomizations.all_globals() # all.foo = 3 """ At this stage, the insertion in the global name space works in the doctest where the library is imported, but is reinitialized in later doctests:: sage: semigroups """