Ask Your Question
0

Can I browse Cython Docs within the notebook()?

asked 2010-08-29 00:28:17 +0200

ccanonc gravatar image

updated 2011-04-28 16:13:42 +0200

Kelvin Li gravatar image

http://pypi.python.org/pypi/bintrees/...

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.

edit retag flag offensive close merge delete

Comments

If they aren't available from Cython, I would be interested to learn more about similar data structures' availability, wherever they may live within Sage. Thx

ccanonc gravatar imageccanonc ( 2010-08-29 00:30:35 +0200 )edit

4 Answers

Sort by ยป oldest newest most voted
1

answered 2010-08-29 00:46:10 +0200

Mike Hansen gravatar image

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:

  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/. 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".

edit flag offensive delete link more

Comments

Clarification, 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.

ccanonc gravatar imageccanonc ( 2010-08-29 01:05:33 +0200 )edit
1

answered 2010-08-29 17:13:51 +0200

niles gravatar image

Tucked 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.

edit flag offensive delete link more
1

answered 2010-08-29 01:17:07 +0200

mvngu gravatar image

You 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.pyc
edit flag offensive delete link more
0

answered 2010-08-29 00:41:40 +0200

mvngu gravatar image

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:

[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.

edit flag offensive delete link more

Comments

I 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

ccanonc gravatar imageccanonc ( 2010-08-29 00:51:27 +0200 )edit

In 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.

mvngu gravatar imagemvngu ( 2010-08-29 00:55:08 +0200 )edit

$ file cython-0.12.1.spkg
cython-0.12.1.spkg: ASCII text
$du --bytes cython-0.12.1.spkg
107 cython-0.12.1.spkg

ccanonc gravatar imageccanonc ( 2010-08-29 01:01:11 +0200 )edit

$ cat cython-0.12.1.spkg
Placeholder spkg file so this binary version of Sage knows this package version used when installing Sage.

ccanonc gravatar imageccanonc ( 2010-08-29 01:02:21 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2010-08-29 00:28:17 +0200

Seen: 624 times

Last updated: Aug 29 '10