ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 29 Aug 2010 17:13:51 +0200Can I browse Cython Docs within the notebook()?https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/http://pypi.python.org/pypi/bintrees/0.3.0
So I notice this webpage that says that Cython has Red-Black Trees (or someone has used Cython to implement them), and I think "Great! How can I get started using them?!"
Of course, I not knowing whether this package is included in sage (or if it is how to get to it); I type "sage: cython?", and I am now unsure where to look. Are the Cython docs included in Sage? What about other packages? Is it standardized within the notebook somehow? Of the included packages, do they have optionally included sub-packages? Tips? Thanks! When I say "included", I mean "bundled" in the distribution.Sun, 29 Aug 2010 00:28:17 +0200https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/Comment by ccanonc for <p><a href="http://pypi.python.org/pypi/bintrees/0.3.0">http://pypi.python.org/pypi/bintrees/...</a></p>
<p>So I notice this webpage that says that Cython has Red-Black Trees (or someone has used Cython to implement them), and I think "Great! How can I get started using them?!"</p>
<p>Of course, I not knowing whether this package is included in sage (or if it is how to get to it); I type "sage: cython?", and I am now unsure where to look. Are the Cython docs included in Sage? What about other packages? Is it standardized within the notebook somehow? Of the included packages, do they have optionally included sub-packages? Tips? Thanks! When I say "included", I mean "bundled" in the distribution.</p>
https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22802#post-id-22802If they aren't available from Cython, I would be interested to learn more about similar data structures' availability, wherever they may live within Sage. ThxSun, 29 Aug 2010 00:30:35 +0200https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22802#post-id-22802Answer by mvngu for <p><a href="http://pypi.python.org/pypi/bintrees/0.3.0">http://pypi.python.org/pypi/bintrees/...</a></p>
<p>So I notice this webpage that says that Cython has Red-Black Trees (or someone has used Cython to implement them), and I think "Great! How can I get started using them?!"</p>
<p>Of course, I not knowing whether this package is included in sage (or if it is how to get to it); I type "sage: cython?", and I am now unsure where to look. Are the Cython docs included in Sage? What about other packages? Is it standardized within the notebook somehow? Of the included packages, do they have optionally included sub-packages? Tips? Thanks! When I say "included", I mean "bundled" in the distribution.</p>
https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?answer=11587#post-id-11587You can find Cython under the site-packages/ directory of the version of Python that is shipped with Sage. For example:
[mvngu@sage sage-4.5.3.alpha2]$ ls local/lib/python/site-packages/Cython
CodeWriter.py Debugging.pyc __init__.pyc Shadow.pyc TestUtils.py
CodeWriter.pyc Distutils Plex StringIOTree.py TestUtils.pyc
Compiler Includes Runtime StringIOTree.pyc Utils.py
Debugging.py __init__.py Shadow.py Tests Utils.pycSun, 29 Aug 2010 01:17:07 +0200https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?answer=11587#post-id-11587Answer by niles for <p><a href="http://pypi.python.org/pypi/bintrees/0.3.0">http://pypi.python.org/pypi/bintrees/...</a></p>
<p>So I notice this webpage that says that Cython has Red-Black Trees (or someone has used Cython to implement them), and I think "Great! How can I get started using them?!"</p>
<p>Of course, I not knowing whether this package is included in sage (or if it is how to get to it); I type "sage: cython?", and I am now unsure where to look. Are the Cython docs included in Sage? What about other packages? Is it standardized within the notebook somehow? Of the included packages, do they have optionally included sub-packages? Tips? Thanks! When I say "included", I mean "bundled" in the distribution.</p>
https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?answer=11590#post-id-11590Tucked in the recesses of the Sage documentation are the commands `search_src`, `search_def`, and `search_doc`. They take a string as argument and return all the files containing that string (well, one searches docstrings, one searches definitions, and the other searches all source code; you can probably guess which is which). So in addition to the other answers here, these commands can give you an idea of _which_ file to look at.Sun, 29 Aug 2010 17:13:51 +0200https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?answer=11590#post-id-11590Answer by mvngu for <p><a href="http://pypi.python.org/pypi/bintrees/0.3.0">http://pypi.python.org/pypi/bintrees/...</a></p>
<p>So I notice this webpage that says that Cython has Red-Black Trees (or someone has used Cython to implement them), and I think "Great! How can I get started using them?!"</p>
<p>Of course, I not knowing whether this package is included in sage (or if it is how to get to it); I type "sage: cython?", and I am now unsure where to look. Are the Cython docs included in Sage? What about other packages? Is it standardized within the notebook somehow? Of the included packages, do they have optionally included sub-packages? Tips? Thanks! When I say "included", I mean "bundled" in the distribution.</p>
https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?answer=11583#post-id-11583In a source distribution of Sage, you also get the source of all standard packages in Sage. Standard packages reside under SAGE_ROOT/spkg/standard. You should be able to uncompress each spkg using tar and bunzip2, then hunt around an uncompressed spkg for the documentation of that upstream package. For example, here is a way to read the documentation of Cython:
[mvngu@sage mvngu]$ ls
dot_sage sage-4.5.3.alpha2
[mvngu@sage mvngu]$ cd sage-4.5.3.alpha2/spkg/standard/
[mvngu@sage standard]$ tar -jxf cython-0.12.1.spkg
[mvngu@sage standard]$ cd cython-0.12.1/src/Doc/
[mvngu@sage Doc]$ ls
About.html FAQ.html overview.html sharing.html
extension_types.html index.html primes.c special_methods.html
Once uncompressed, you could also read the source of the upstream package.Sun, 29 Aug 2010 00:41:40 +0200https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?answer=11583#post-id-11583Comment by ccanonc for <p>In a source distribution of Sage, you also get the source of all standard packages in Sage. Standard packages reside under SAGE_ROOT/spkg/standard. You should be able to uncompress each spkg using tar and bunzip2, then hunt around an uncompressed spkg for the documentation of that upstream package. For example, here is a way to read the documentation of Cython:</p>
<pre><code>[mvngu@sage mvngu]$ ls
dot_sage sage-4.5.3.alpha2
[mvngu@sage mvngu]$ cd sage-4.5.3.alpha2/spkg/standard/
[mvngu@sage standard]$ tar -jxf cython-0.12.1.spkg
[mvngu@sage standard]$ cd cython-0.12.1/src/Doc/
[mvngu@sage Doc]$ ls
About.html FAQ.html overview.html sharing.html
extension_types.html index.html primes.c special_methods.html
</code></pre>
<p>Once uncompressed, you could also read the source of the upstream package.</p>
https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22799#post-id-22799$ file cython-0.12.1.spkg
<br>
cython-0.12.1.spkg: ASCII text
<br>
$du --bytes cython-0.12.1.spkg
<br>
107 cython-0.12.1.spkgSun, 29 Aug 2010 01:01:11 +0200https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22799#post-id-22799Comment by ccanonc for <p>In a source distribution of Sage, you also get the source of all standard packages in Sage. Standard packages reside under SAGE_ROOT/spkg/standard. You should be able to uncompress each spkg using tar and bunzip2, then hunt around an uncompressed spkg for the documentation of that upstream package. For example, here is a way to read the documentation of Cython:</p>
<pre><code>[mvngu@sage mvngu]$ ls
dot_sage sage-4.5.3.alpha2
[mvngu@sage mvngu]$ cd sage-4.5.3.alpha2/spkg/standard/
[mvngu@sage standard]$ tar -jxf cython-0.12.1.spkg
[mvngu@sage standard]$ cd cython-0.12.1/src/Doc/
[mvngu@sage Doc]$ ls
About.html FAQ.html overview.html sharing.html
extension_types.html index.html primes.c special_methods.html
</code></pre>
<p>Once uncompressed, you could also read the source of the upstream package.</p>
https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22798#post-id-22798$ cat cython-0.12.1.spkg
<br>
Placeholder spkg file so this binary version of Sage knows this package version used when installing Sage.
Sun, 29 Aug 2010 01:02:21 +0200https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22798#post-id-22798Comment by mvngu for <p>In a source distribution of Sage, you also get the source of all standard packages in Sage. Standard packages reside under SAGE_ROOT/spkg/standard. You should be able to uncompress each spkg using tar and bunzip2, then hunt around an uncompressed spkg for the documentation of that upstream package. For example, here is a way to read the documentation of Cython:</p>
<pre><code>[mvngu@sage mvngu]$ ls
dot_sage sage-4.5.3.alpha2
[mvngu@sage mvngu]$ cd sage-4.5.3.alpha2/spkg/standard/
[mvngu@sage standard]$ tar -jxf cython-0.12.1.spkg
[mvngu@sage standard]$ cd cython-0.12.1/src/Doc/
[mvngu@sage Doc]$ ls
About.html FAQ.html overview.html sharing.html
extension_types.html index.html primes.c special_methods.html
</code></pre>
<p>Once uncompressed, you could also read the source of the upstream package.</p>
https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22800#post-id-22800In your version of Sage, try to determine whether or not it is a source or binary distribution. What do you get if you do these?
$ file cython-0.12.1.spkg
$ du -sh cython-0.12.1.spkg
In a source distribution, the size of the cython spkg should be few kilobytes.Sun, 29 Aug 2010 00:55:08 +0200https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22800#post-id-22800Comment by ccanonc for <p>In a source distribution of Sage, you also get the source of all standard packages in Sage. Standard packages reside under SAGE_ROOT/spkg/standard. You should be able to uncompress each spkg using tar and bunzip2, then hunt around an uncompressed spkg for the documentation of that upstream package. For example, here is a way to read the documentation of Cython:</p>
<pre><code>[mvngu@sage mvngu]$ ls
dot_sage sage-4.5.3.alpha2
[mvngu@sage mvngu]$ cd sage-4.5.3.alpha2/spkg/standard/
[mvngu@sage standard]$ tar -jxf cython-0.12.1.spkg
[mvngu@sage standard]$ cd cython-0.12.1/src/Doc/
[mvngu@sage Doc]$ ls
About.html FAQ.html overview.html sharing.html
extension_types.html index.html primes.c special_methods.html
</code></pre>
<p>Once uncompressed, you could also read the source of the upstream package.</p>
https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22801#post-id-22801I got:
$ tar -jxf cython-0.12.1.spkg
bzip2: (stdin) is not a bzip2 file.
tar: Child returned status 2
tar: Exiting with failure status due to previous errors
Sun, 29 Aug 2010 00:51:27 +0200https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22801#post-id-22801Answer by Mike Hansen for <p><a href="http://pypi.python.org/pypi/bintrees/0.3.0">http://pypi.python.org/pypi/bintrees/...</a></p>
<p>So I notice this webpage that says that Cython has Red-Black Trees (or someone has used Cython to implement them), and I think "Great! How can I get started using them?!"</p>
<p>Of course, I not knowing whether this package is included in sage (or if it is how to get to it); I type "sage: cython?", and I am now unsure where to look. Are the Cython docs included in Sage? What about other packages? Is it standardized within the notebook somehow? Of the included packages, do they have optionally included sub-packages? Tips? Thanks! When I say "included", I mean "bundled" in the distribution.</p>
https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?answer=11585#post-id-11585From that webpage, someone has just used Cython to implement them -- they don't come with Cython. You can install that package in the same way as most packages on PyPI:
1. Download bintrees-0.3.0.tar.gz from PyPI
2. Extract the tarball.
3. Run
sage -python setup.py install
4. You'll be able to run `import bintrees` from within your Sage sessions now.
As for using the package, you'll have to look at that package's specific documentation.
The Cython documentation is not built / included in Sage, but you can find it at [http://docs.cython.org/][1]. For other packages, it varies. For example, you can find the Pari documentation under `$SAGE_ROOT/local/share/pari/doc/`.
None of this package specific documentation is specifically made available from within the notebook. When you type in `cython?` from the notebook, you're getting the documentation a specific function called `cython` within Sage -- this is different than the documentation for Cython itself.
I'm not sure what you mean about "optional included sub-packages".
[1]: http://docs.cython.org/Sun, 29 Aug 2010 00:46:10 +0200https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?answer=11585#post-id-11585Comment by ccanonc for <p>From that webpage, someone has just used Cython to implement them -- they don't come with Cython. You can install that package in the same way as most packages on PyPI:</p>
<ol>
<li><p>Download bintrees-0.3.0.tar.gz from PyPI</p></li>
<li><p>Extract the tarball.</p></li>
<li><p>Run </p>
<pre><code>sage -python setup.py install
</code></pre></li>
<li><p>You'll be able to run <code>import bintrees</code> from within your Sage sessions now.</p></li>
</ol>
<p>As for using the package, you'll have to look at that package's specific documentation.</p>
<p>The Cython documentation is not built / included in Sage, but you can find it at <a href="http://docs.cython.org/">http://docs.cython.org/</a>. For other packages, it varies. For example, you can find the Pari documentation under <code>$SAGE_ROOT/local/share/pari/doc/</code>. </p>
<p>None of this package specific documentation is specifically made available from within the notebook. When you type in <code>cython?</code> from the notebook, you're getting the documentation a specific function called <code>cython</code> within Sage -- this is different than the documentation for Cython itself.</p>
<p>I'm not sure what you mean about "optional included sub-packages".</p>
https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22797#post-id-22797Clarification, regarding "sub-packages": My question was, does sage allow included libs to be further configured? For example (whether standard or not), could an included library pull in more libs than Sage might normally? Thank you for your non-notebook solution. I'm a new user. Sun, 29 Aug 2010 01:05:33 +0200https://ask.sagemath.org/question/7647/can-i-browse-cython-docs-within-the-notebook/?comment=22797#post-id-22797