GettingStarted PDF
GettingStarted PDF
GettingStarted PDF
Getting Started
The labs in this curriculum aim to introduce computational and mathematical concepts, walk through
implementations of those concepts in Python, and use industrial-grade code to solve interesting,
relevant problems. Lab assignments are usually about 510 pages long and include code examples
(yellow boxes), important notes (green boxes), warnings about common errors (red boxes), and
about 37 exercises (blue boxes). Get started by downloading the lab manual(s) for your course from
http://foundations-of-applied-mathematics.github.io/.
Submitting Assignments
Labs
Every lab has a corresponding specications le with some code to get you started and to make your
submission compatible with automated test drivers. Like the lab manuals, these materials are hosted
at http://foundations-of-applied-mathematics.github.io/.
Download the .zip le for your course, unzip the folder, and move it somewhere where it
won't get lost. This folder has some setup scripts and a collection of folders, one per lab, each of
which contains the specications le(s) for that lab. See Student-Materials/wiki/Lab-Index for
the complete list of labs, their specications and data les, and the manual that each lab belongs to.
Achtung!
Do notmove or rename the lab folders or the enclosed specications les; if you do, the test
drivers will not be able to nd your assignment. Make sure your folder and le names match
Student-Materials/wiki/Lab-Index.
To submit a lab, modify the provided specications le and use the le-sharing program
specied by your instructor (discussed in the next section). The instructor will drop feedback
les in the lab folder after grading the assignment. For example, the Introduction to Python lab
has the specications le PythonIntro/python_intro.py. To complete that assignment, modify
PythonIntro/python_intro.py and submit it via your instructor's le-sharing system. After grad-
ing, the instructor will create a le called PythonIntro/PythonIntro_feedback.txt with your score
and some feedback.
1
2 Appendix A. Getting Started
Homework
Non-lab coding homework should be placed in the _Homework/ folder and submitted like a lab
assignment. Be careful to name your assignment correctly so the instructor (and test driver) can nd
it. The instructor may drop specications les and/or feedback les in this folder as well.
Setup
Achtung!
We strongly recommend using a Unix-based operating system (Mac or Linux) for the labs.
Unix has a true bash terminal, works well with git and python, and is the preferred platform
for computational and data scientists. It is possible to do this curriculum with Windows, but
expect some road bumps along the way.
There are two ways to submit code to the instructor: with git (http://git-scm.com/), or with
a le-syncing service like Google Drive. Your instructor will indicate which system to use.
There are many websites for hosting online git repositories. Your instructor will indicate which
web service to use, but we only include instructions here for setup with Bitbucket.
1. Sign up. Create a Bitbucket account at https://bitbucket.org. If you use an academic email
address (ending in .edu, etc.), you will get free unlimited public and private repositories.
2. Make a new repository. On the Bitbucket page, click the + button from the menu on the
CREATE
left and, under Repository
, select . Provide a name for the repository, mark the
private
repository as , and make sure the repository type is Git . ForInclude a README? ,
No
select (if you accidentally include a README, delete the repository and start over). Un-
der Advanced settings No forks
, enter a short description for your repository, select un-
Python
der forking, and select as the language. Finally, click the blueCreate repository
button. Take note of the URL of the webpage that is created; it should be something like
https://bitbucket.org/<name>/<repo>.
3
3. Give the instructor access to your repository. On your newly created Bitbucket repository
page (https://bitbucket.org/<name>/<repo> or similar), go to Settings in the menu to
the left and selectUser and group access , the second option from the top. Enter your
Users
instructor's Bitbucket username under and clickAdd Write
. Select the blue button so
your instructor can read from and write feedback to your repository.
4. Connect your folder to the new repository. In a shell application (Terminal on Linux or Mac,
or Git Bash (https://gitforwindows.org/) on Windows), enter the following commands.
# Add the contents of this folder to git and update the repository.
$ git add --all
$ git commit -m "initial commit"
$ git push origin master
For example, if your Bitbucket username is greek314, the repository is called acmev1, and the
folder is called Student-Materials/ and is on the desktop, enter the following commands.
# Record credentials.
$ git config --local user.name "archimedes"
4 Appendix A. Getting Started
# Add the contents of this folder to git and update the repository.
$ git add --all
$ git commit -m "initial commit"
$ git push origin master
At this point you should be able to see the les on your repository page from a web browser. If
you enter the repository URL incorrectly in the git remote add origin step, you can reset
it with the following line.
5. Download data les. Many labs have accompanying data les. To download these les, navi-
gate to your clone and run the download_data.sh bash script, which downloads the les and
places them in the correct lab folder for you. You can also nd individual data les through
Student-Materials/wiki/Lab-Index.
6. Install Python package dependencies. The labs require several third-party Python packages
that don't come bundled with Anaconda. Run the following command to install the necessary
packages.
7. (Optional) Clone your repository. If you want your repository on another computer after
completing steps 14, use the following commands.
Using Git
Git manages the history of a le system through commits, or checkpoints. Use git status to see
the les that have been changed since the last commit. These changes are then moved to the staging
area, a list of les to save during the next commit, with git add <filename(s)>. Save the changes
in the staging area with git commit -m "<A brief message describing the changes>".
Figure A.1: Git commands to stage, unstage, save, or discard changes. Commit messages are recorded
in the log.
All of these commands are done within a clone of the repository, stored somewhere on a com-
puter. This repository must be manually synchronized with the online repository via two other git
commands: git pull origin master, to pull updates from the web to the computer; and git
push origin master, to push updates from the computer to the web.
Online Repository
Computer
Figure A.2: Exchanging git commits between the repository and a local clone.
6 Appendix A. Getting Started
Command Explanation
git status Display the staging area and untracked changes.
git pull origin master Pull changes from the online repository.
git push origin master Push changes to the online repository.
git add <filename(s)> Add a le or les to the staging area.
git add -u Add all modied, tracked les to the staging area.
git commit -m "<message>" Save the changes in the staging area with a given message.
git checkout -- <filename> Revert changes to an unstaged le since the last commit.
git reset HEAD -- <filename> Remove a le from the staging area.
git diff <filename> See the changes to an unstaged le since the last commit.
git diff --cached <filename> See the changes to a staged le since the last commit.
git config --local <option> Record your credentials (user.name, user.email, etc.).
Note
When pulling updates with git pull origin master, your terminal may sometimes display
the following message.
This means that someone else (the instructor) has pushed a commit that you do not yet have,
while you have also made one or more commits locally that they do not have. This screen,
displayed in vim (https://en.wikipedia.org/wiki/Vim_(text_editor)), is asking you to
enter a message (or use the default message) to create a merge commit that will reconcile both
changes. To close this screen and create the merge commit, type :wq and press enter.
$ cd ~/Desktop/Student-Materials/
$ git pull origin master # Pull updates.
### Make changes to a file.
$ git add -u # Track changes.
$ git commit -m "Made some changes." # Commit changes.
$ git push origin master # Push updates.
7
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
PythonIntro/python_intro.py
modified: PythonIntro/python_intro.py
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean