forked from numerical-mooc/numerical-mooc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into relax_dev
- Loading branch information
Showing
59 changed files
with
105,111 additions
and
132,528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.ipynb_checkpoints/ | ||
*.pyc | ||
.ipynb_checkpoints | ||
.pyc | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
lessons/00_getting_started/00_01_Intro_to_the_command_line.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#Intro to the command line | ||
|
||
Welcome! The command can be one of the most powerful ways to interact with a variety of computer systems, but it can also be a little confusing at first glance. This mini-crash-course should help familiarize you with the basics of command line usage and navigation. | ||
|
||
|
||
##Who am I? | ||
|
||
Time to get started! You likely know your username since you've just logged in, but sometimes you may have multiple accounts with slight variations on a username. | ||
|
||
First, please open up a terminal using the menu in the upper-left corner (on Red Hat) and selecting | ||
|
||
> Applications -> System Tools -> Terminal | ||
You can always ask the terminal who you are by entering | ||
|
||
```Bash | ||
whoami | ||
``` | ||
|
||
and hitting \<Enter\>. (From now on, after typing in a command, just hit \<Enter\> unless we tell you otherwise.) | ||
|
||
 | ||
|
||
##Where am I? | ||
|
||
We know who we are, time to find out *where* we are. You can always find out what folder you're in by using the "print working directory" command, or `pwd`. Try it out! | ||
|
||
```Bash | ||
pwd | ||
``` | ||
|
||
 | ||
|
||
We're in our home directory. This is the base directory for a regular user in Linux. In the SEAS labs, the home directory is always `/home/seas/<username>`. If you're using your own Linux machine, the home directory is probably `/home/<username>`. If you're on a Mac, the home directory is `/Users/<username>` (they like to be different). | ||
|
||
##What's in here? | ||
|
||
We know who we are and where we are, now it's time to figure out what's in here. We use the "list" command, `ls`, to view any files or directories that are in the current folder. | ||
|
||
```Bash | ||
ls | ||
``` | ||
|
||
 | ||
|
||
The items you see above in the gif are all folders. They're the usual folders created by default in Red Hat Linux. Your home folder is actually the same folder as your Titan network drive on Windows, so you may have other files and folders in your home directory. | ||
|
||
##How do I go there? | ||
|
||
To navigate to a new folder, we use the change directory command, `cd`, followed by the name of the folder. While you *can* type out the full folder name, it's usually nicer to use what's called Tab-completion. | ||
|
||
Let's change to the `Pictures` directory. Type `cd Pi` and then hit the TAB key to complete the directory name. Then hit \<Enter\> | ||
|
||
Now you're in the `Pictures` directory. It's probably empty, but you can check with `ls`. | ||
|
||
To go back to your home directory, type `cd ..` | ||
|
||
The `..` is a command-line shortcut to move "up" one folder in a directory tree. Try `cd`-ing into a few other folders and then returning back to your home directory to get the hang of moving around. | ||
|
||
 | ||
|
||
###Multiple tab-completions | ||
|
||
If there are multiple possible completions for a partial directory name, you can ask the terminal to display them by hitting TAB twice. Try entering | ||
|
||
```Bash | ||
cd Do | ||
``` | ||
|
||
and then hit TAB twice to see the list of matching directories. Then you can add a `c` and Tab-complete `Documents`. | ||
|
||
 | ||
|
||
##Quick config step | ||
|
||
Now that we have a handle on basic terminal navigation, we are going to make a few tweaks to this setup to make it friendlier. | ||
Copy the two lines below by selecting them and hitting Ctrl+c and then paste them into the terminal using Ctrl+Shift+v and hit \<Enter\>. **Note** that Ctrl+v doesn't work, you need to add Shift. | ||
|
||
```Bash | ||
echo "export PATH=/opt/anaconda/bin:\$PATH" >> .bashrc | ||
echo "export PS1=\"\u \w \"" >> .bashrc | ||
``` | ||
|
||
(If you are following along and aren't at GW, don't copy the first line, that only applies to the GW Linux labs) | ||
|
||
Now, to activate the options we just selected, type the following line in the terminal and hit \<Enter\> | ||
|
||
```Bash | ||
source .bashrc | ||
``` | ||
|
||
It should look a little something like this: | ||
|
||
 | ||
|
||
##Fire up a jupyter notebook! | ||
|
||
It's time to get started! If you're at GW then everything is already installed, just run | ||
|
||
```Bash | ||
jupyter notebook | ||
``` | ||
|
||
in a terminal and it will launch a notebook server in your browser. If you *aren't* at GW, then see the next module in Getting Started on installing Python and Jupyter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#Jupyter Install | ||
|
||
This guide is to help you get Jupyter notebooks up and running on your personal computer. | ||
|
||
##1. Install Anaconda | ||
|
||
There are several ways to install Python and Jupyter and all of the required libraries to complete this course. You are welcome to try out any of them, but we **strongly** suggest using the Anaconda Python Distribution. It is up-to-date (unlike the versions of Python that may already exist on your Linux or OSX machine) and it also comes with `conda`. We'll get to `conda` a little later, but believe us, it's awesome and you want to have it. | ||
|
||
###Download the installer | ||
|
||
First download the Anaconda installer. Visit http://continuum.io/downloads to download the appropriate installer for your operating system. | ||
|
||
**You must first click the link that says "I Want Python 3.4*"** to select the correct installer. | ||
|
||
 | ||
|
||
|
||
###Run the installer | ||
|
||
Follow the appropriate instructions for your operating system listed on the [Anaconda Install Page](http://docs.continuum.io/anaconda/install). For Linux users, make sure to answer "yes" when the installer asks about editing your `PATH`. | ||
|
||
 | ||
|
||
Also note that on both Linux and OSX, you have to close the current terminal window and re-open it before the Anaconda installation will be available. | ||
|
||
##2. Install Jupyter and other libraries | ||
|
||
Once Anaconda is installed, you can then use the included `conda` package to install all of the necessary packages for the course. Open a terminal and run | ||
|
||
```Bash | ||
conda install jupyter numpy scipy sympy matplotlib | ||
``` | ||
|
||
##3. Test your installation | ||
Once `conda` is finished you should be ready to go! Open a terminal and run | ||
|
||
```Bash | ||
jupyter notebook | ||
``` | ||
|
||
to launch a notebook server. |
107 changes: 107 additions & 0 deletions
107
lessons/00_getting_started/00_03_Intro_to_Jupyter_notebook.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Intro to Jupyter notebooks | ||
|
||
## What is the Jupyter Notebook? | ||
We'll work extensively with [Jupyter Notebooks](https://jupyter-notebook.readthedocs.org/en/latest/notebook.html) (formerly IPython Notebooks) in this course. They are media-rich documents that combine text with markown formatting, typeset mathematics with MathJax, and executable Python statements. | ||
|
||
The best way to understand the notebooks is to try them out, so let's get started! | ||
|
||
## Launching the notebook server | ||
|
||
To launch the notebook server, first open up a terminal and then enter | ||
|
||
```Bash | ||
jupyter notebook | ||
``` | ||
|
||
This will start the notebook server. It *should* automatically open the main page of the notebook server in your default browser, but if it doesn't, simply open the browser of your choice and enter | ||
|
||
``` | ||
http://localhost:8888/tree | ||
``` | ||
|
||
in the address bar. | ||
|
||
This will bring up a simple file-browser that will show the contents of the directory where you've launched the terminal from. Click on the `New Notebook` button and then select **Python 3** at the bottom to create your first notebook. | ||
|
||
 | ||
|
||
##Executing a code cell | ||
|
||
Below the toolbars, you'll see a single code cell, prepended with `In [ ]:`. This cell can contain an arbitrarily long code segment, but we'll start with a simple one liner. In that lone code cell, type | ||
|
||
```Python | ||
x = 5 | ||
``` | ||
|
||
and then hit *Shift+Enter*. If you just hit Enter you'll find that it will simply add another line to the current cell. So remember, **to execute a cell**, it's **Shift+Enter**. | ||
|
||
So what happened? We've assigned the label x to the number 5. And also you should see that the label of that cell will now read `In[1]:` because that's the first statement we've executed in this Python kernel. You'll also notice that the notebook has created a new cell, since we already used the only existing cell. | ||
|
||
In this new cell, let's try to print out the value we assigned to x, so enter | ||
|
||
|
||
```Python | ||
print(x) | ||
``` | ||
|
||
and then hit **Shift+Enter**. And there's the output we expect! The cell gets labeled `In[2]:` and the output of that command is printed immediately below the cell. | ||
|
||
The whole procedure should look something like this: | ||
|
||
 | ||
|
||
##The Kernel | ||
Don't worry too much about what the "kernel" is, but the main point to remember here is that we can assign a variable in one cell but still access it in a separate cell. The cells are ways for *us* to divide up our thoughts and our code, but everything is connected underneath. | ||
|
||
##Overwriting variables | ||
|
||
Since each cell is interacting with the same Python instance, if we give `x` a new value and then enter `print(x)` we'll get that new value. That's pretty straight forward —but what if we then delete the cell where we gave `x` a new value? | ||
|
||
Let's take a look! | ||
|
||
 | ||
|
||
Even though we deleted the cell where we assigned `x = 7`, the assignment is still valid. In fact, the assignment will remain valid until we explicitly execute a cell that sets x equal to a new value, or until we completely restart this Jupyter Notebook instance. | ||
|
||
##Markdown | ||
Markdown is a *writing format* that makes it easy to type well-formatted text that is rendered into properly formatted XHTML. It's seriously awesome. Cells in Jupyter notebooks can be used for many things: to run Python, to embed media, or to write text in Markdown. This allows us to write notes about what we're doing, what the code is doing, what we're *trying* to do, whatever we like! These notes can be for ourselves, to document our work, or to share with others. | ||
|
||
To create a Markdown cell in a notebook, click on an empty cell, then click on the Dropdown list (by default, it will say "Code") and select "Markdown"—as shown below. | ||
|
||
Markdown is also (sort of) code, so after you type some text, you will also hit *Shift+Enter* to execute the cell and render the Markdown text. Try it out! Just type out a sentence or two in a markdown cell, then hit *Shift+Enter* to render the text. | ||
|
||
 | ||
|
||
##Markdown Math | ||
|
||
Markdown can do more than just render simple text, it can also render LaTeX-style equations using **MathJax**! | ||
|
||
* For inline math, wrap LaTeX inside single `$` signs | ||
`$...$` | ||
* For single-line rendering, wrap LaTeX inside double `$$` signs | ||
`$$...$$` | ||
|
||
 | ||
|
||
**Note:** | ||
|
||
Be aware that math typesetting is handled by MathJax and not by LaTeX. While the vast majority of MathJax syntax is identical to LaTeX, there are a few small differences (especially when it comes to matrix commands). So if you find something doesn't typeset the way you expect, Google around to make sure you're using the correct command. | ||
|
||
##More Markdown Syntax | ||
There are several references to learn Markdown tricks, but we especially like the summary by [John Gruber](http://daringfireball.net/projects/markdown/syntax). A few features that we find particularly useful are listed below. | ||
|
||
For italics, wrap text in single `*`: `*this will be italic*` | ||
For bold, wrap text in double `**`: `**this will be bold**` | ||
For a bulleted list, start the line with an `*`, then type a space followed by the bullet item | ||
``` | ||
* list item | ||
* another list item | ||
* and another | ||
``` | ||
|
||
##Moving Cells Around | ||
You'll often find that you want to add or delete cells, or just move them around. To move a cell, just click on it to select it, then use the Up- and Down-arrows in the toolbar to change the position of the cell. | ||
|
||
 | ||
|
||
To add a cell, you can click the + button in the toolbar. Once you're comfortable with the notebook layout, you can also click on Help -> Keyboard Shortcuts to find out various shortcuts for adding, deleting and managing cell position and type. |
Oops, something went wrong.