Sage Days 96

Sage days 96 to be held at the Fields Institute for the program Teichmüller Theory and its Connections to Geometry, Topology and Dynamics. The schedule is available on the Fields website. This wiki page will be updated with all documents relative to the workshop (worksheets, tutorials, demos, nice pictures, etc).

In order to assist to the workshop you are asked to come with your laptop (though you are also welcome without laptop). It would also be great if you could make sure that Sage is installed on it (see "Sage Installation" below).

Workshop dinner on thursday (Sky Dragon on Dundas and Spadina).

Worksheets

Sage Installation

The installation procedure depends on your operating system:

Installing flipper, snappy, flatsurf and surface_dynamics

We will be interested in these Sage days to four Python-Sage modules that provide many tools to work with surfaces and 3-dimensional manifolds

These packages are installed through pip. Depending how you did install Sage you might run in different kind of complications.

Generic Installation

This installation would work in most situations. Though if you happen to be in one of the specific situations listed below, just jump to that section.

Mac OS X specifics

If you are using the binaries for Mac OS X, the computer might complain with could not fetch URL .... In that situation, you can try the two following solutions

  1. You do have Xcode installed with the command line tools. In this case you can recompile the Python shipped with Sage with SSL support with
     $ sage -i openssl
     $ sage -f python2 
    Then go back to the instructions "Installing flipper, snappy, flatsurf and surface_dynamics".
  2. The alternative to option 1 is to download each package independently: and then install them via
     $ sage -pip install flipper-0.12.3.tar.gz
     $ sage -pip install surface_dynamics-0.4.0.tar.gz
     $ sage -pip install snappy-2.6.tar.gz
     $ sage -pip master.zip

Ubuntu 16.04 with ppa

If you run Ubuntu 16.04 and you install Sage with the ppa then do

$ sage -sh
(sage-sh)$ pip install flipper --user
(sage-sh)$ pip install surface_dynamics --user
(sage-sh)$ pip install snappy --user
(sage-sh)$ exit

(The sage -sh command brings you to a special environment where you have access to Sage Python)

Ubuntu >= 18.04 and Debian >= 8.0 packages

If you happen to have installed the packages sagemath and sagemath-jupyter from your package manager in Debian/Ubuntu then you would need to do

$ source /usr/share/sagemath/bin/sage-env
$ pip install flipper --user
$ pip install surface_dynamics --user
$ pip install snappy --user

For the installation of flatsurf, follows the instruction at https://github.com/videlec/sage-flatsurf and replace any instance of sage -pip by pip.

Archlinux

Do

$ sage -sh
(sage-sh)$ pip2 install flipper --user
(sage-sh)$ pip2 install surface_dynamics --user
(sage-sh)$ pip2 install snappy --user
(sage-sh)$ exit
$

For the installation of flatsurf, follows the instruction at https://github.com/videlec/sage-flatsurf and replace any instance of sage -pip by pip.

Windows

Before following the generic instruction do

(sage-sh) $ apt-cyg install libcrypt-devel
(sage-sh) $ apt-cyg install liblapack-devel

Organizers and participants

See the Fields Institute webpage.

Questions and answers

Saul: Why does snake_case have that name?
Vincent: See the discussion here - https://en.wikipedia.org/wiki/Snake_case.

Derrick: If I'm running Sage on a Windows installation, how to I make Jupyter launch in the correct directory?
Derrick: [question 41348 on ask](https://ask.sagemath.org/question/41348/sagemath-windows-81-launching-jupyter-from-another-directory-or-drive/)

Aaron: Does Python have a built-in way to iterate over the product of two iterators that don't necessarily terminate?
Vincent: No, but Sage does have a [cantor_product](https://doc.sagemath.org/html/en/reference/misc/sage/misc/mrange.html). Example:

   1 P = sage.misc.mrange.cantor_product(NN, repeat=2)
   2 for _ in range(10):
   3     print(next(P))

produces (0, 0), (1, 0), (0, 1), (2, 0), (1, 1), (0, 2)... Although the feature isn't documented, iterating up to (0, n) only requires n calls to NN.next().

Rex: Let L be a list. To get a new list K with the elements of L in reverse order, we can write K = L[::-1] What is each the colons and the -1 telling Sage to do exactly?
Vincent: These are [Python slices](https://docs.python.org/2.3/whatsnew/section-slices.html)

Aaron: How do we specify a quadratic differential?
Vincent: triangulated surface, where the lengths live in some arithmetic. (Floating point numbers are not numbers!)

Saul: is there a way to start with floating point surface, and quickly rule out "small" components (eg no short cylinders)?

Rex: I'm running something that's printing a list of integers as it runs. Is there any way to tell Sage to truncate the old output (I'm only interested in seeing how far it has gone along)?
Vincent: If you do

from IPython.display import clear_output

then you can use the function clear_output() to remove everything in the output. Though this slows down a lot the computation.

The following previous answer does not work (in Jupyter)

from sys import stdout
from time import sleep
stdout.write('hello\r')
sleep(1)   # wait for 1 sec
stdout.write('bouh \r')
sleep(1)   # wait for 1 sec
stdout.write('next \r')

The character '\r' means carriage return and go back the the begining of the line so that you can erase what you just wrote. But with this method, it only works with one line being updated.

Rex: Do different packages ever have any dependencies such that uninstalling one package causes problems for others? For example, if I uninstall flipper at some later point in time (say to reinstall an updated version), could this cause issues with other packages that might rely on flipper?
Saul: Yes, this could happen. Package management is tricky.

Rex: Also, is there a simpler way to update a package than uninstalling and reinstalling it?
Saul:Something like

pip install <PACKAGE> --user --upgrade 

We used to coordinate using a pad on https://mensuel.framapad.org/ that is now closed.