Skip to content

sympy/scipy-2017-codegen-tutorial

Repository files navigation

SciPy 2017 Codegen Tutorial

Introduction

This repository contains all of the source code and Jupyter notebooks for the SciPy 2017 tutorial "Automatic Code Generation with SymPy".

The original proposal for this tutorial can be found on the SymPy Wiki.

The statically rendered Jupyter notebooks in this repository can be viewed at sympy.org/scipy-2017-codegen-tutorial or on NBViewer.

Software Installation

We leverage the Conda package manager for installation of the necessary software on the three most popular platforms. Please install either Anaconda or Miniconda using the instructions provided at the download links.

If you are using Windows, please also install the Visual C++ Build Tools for proper Cython compilation with Python 3.5+. Install this before you arrive at the tutorial, as it takes some time.

You will need to download and unzip or clone this repository with Git so that the files are available on your computer. For example:

> wget https://github.com/sympy/scipy-2017-codegen-tutorial/archive/master.zip
> unzip master.zip

or:

> git clone https://github.com/sympy/scipy-2017-codegen-tutorial.git

At the command line, change into the repository directory:

> cd /path/to/scipy-2017-codegen-tutorial

Creating a conda environment from environment.yml

Once you have conda installed, you can choose from one of our environment files that specifies our conda environment (named codegen17):

  • environment.yml (relies on your system compiler, e.g. gcc/clang/msvc on linux/osx/win)
  • environment-gcc.yml (installs conda's version of gcc)

we strongly encourage user to use environment.yml. At the command line, you can create this environment by executing e.g.:

> conda env create -f environment.yml

Run this command before you arrive at the tutorial, as it takes some time.

When installation is complete you may activate the environment by typing:

> activate codegen17

on Windows or using Bash on Linux/Mac):

$ source activate codegen17

To check to see if everything is installed correctly type:

(codegen17)> python test_installation.py

If there are no errors or warnings you have installed the software correctly.

To exit the environment you type:

(codegen17)> deactivate

If you for some reason want to remove the environment you can do so after deactivating by typing:

> conda env remove --name codegen17

on windows, and:

$ source deactivate

on Linux/Mac (using bash).

At this point you have everything installed to run the code in the tutorial.

Running the notebooks

After activating the codegen17 environment start Jupyter in the notebooks directory:

(codegen17)> jupyter notebook index.ipynb

A web interface should open in your web browser (default address http://localhost:8888). Note that Ctrl-C will stop the notebook server.

Optional Installation/Run Methods

Host a jupyter server using docker

If docker is installed it is possible to simply launch a jupyter notebook running in the correct environment by writing:

$ bin/host-jupyter-using-docker.sh

Note that it will download roughly ~1 GiB first time you run the command. Also note that you do not need to have conda installed on your machine to do this (conda is installed in the dockerimage).

Run notebooks using binder

Using only a web-browser (and an internet connection) it is possible to explore the notebooks here: (by the courtesy of the people behind mybinder)

Binder

Developing the notebooks

Note that you should remove the last line of environment.yml (i.e. scipy2017codegen) if you intend to make changes to the scipy2017codegen package (do not commit that change however). Otherwise conda will pull the package from: https://anaconda.org/SymPy/scipy2017codegen

It is recommended that you run python setup.py develop after having activated the codegen17 environment lacking our above mentioned package.

CI status

Below are the build status of the CI services set up to test the tutorial notebooks.

Travis CI (OS X)

Travis status

AppVeyor (Windows)

AppVeyor status

CircleCI (Linux - tests environment.yml)

Circle CI status

Drone (Dockerized Ubuntu 16.04 - tests environment-nogcc.yml)

Drone status