12.07.2015 Views

Sage Developer's Guide - Mirrors

Sage Developer's Guide - Mirrors

Sage Developer's Guide - Mirrors

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Sage</strong> Developer’s <strong>Guide</strong>, Release 6.1.1from borel_measure import BorelMeasurefrom banach_tarski import BanachTarskiParadoxbut it is generally better to use the lazy import framework:from sage.misc.lazy_import import lazy_importlazy_import(’sage.measure_theory.borel_measue’, ’BorelMeasure’)lazy_import(’sage.measure_theory.banach_tarski’, ’BanachTarskiParadox’)Then in the file SAGE_ROOT/src/sage/all.py, add a linefrom sage.measure_theory.all import *4.1.3 An Example Is Worth a Thousand WordsFor all of the conventions discussed here, you can find many examples in the <strong>Sage</strong> library. Browsing through thecode is helpful, but so is searching: the functions search_src, search_def, and search_doc are worth knowingabout. Briefly, from the “sage:” prompt, search_src(string) searches <strong>Sage</strong> library code for the stringstring. The command search_def(string) does a similar search, but restricted to function definitions, whilesearch_doc(string) searches the <strong>Sage</strong> documentation. See their docstrings for more information and moreoptions.4.1.4 Headings of <strong>Sage</strong> Library Code FilesThe top of each <strong>Sage</strong> code file should follow this format:r"""AUTHORS:- YOUR NAME (2005-01-03): initial version- person (date in ISO year-month-day format): short descEXAMPLES::"""#*****************************************************************************# Copyright (C) 2013 YOUR NAME ## This program is free software: you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation, either version 3 of the License, or# (at your option) any later version.# http://www.gnu.org/licenses/#*****************************************************************************As an example, see SAGE_ROOT/src/sage/rings/integer.pyx which contains the implementation for Z.The AUTHORS: section is redundant, the authoritative log for who wrote what is always the git repository (see theoutput of git blame). Nevertheless, it is sometimes useful to have a very rough overview over the history, especiallyif a lot of people have been working on that source file.4.1. General Conventions 21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!