Lecture 2 - HW1,numpy arrays, matplotlib, and git 2020.4.14
Review of Python Basics from Lecture 1
Topics from Lecture 1 Lists Strings, ints, floats Dicts Objects, attributes, methods (Tuples,) Functions {sets} Importing .py files/libraries
slides, hws, solutions are posted here: neuropython.com/calendar
Recorded zoom lectures will be accessible via courseworks (more fun in real time though)
HW1 Solutions
Numpy Arrays (see slides)
Plotting with Matplotlib (see slides)
%matplotlib notebook %matplotlib inline ● interactivity in old notebook ● sends png to browser ● doesn't work in jupyter lab ● no panning or zooming ● need to create separate figures ● new figure for each cell ● ability to update figures ● no changes to previous figures %matplotlib widget ● interactive widget ● all figure features ● need to create separate figures explicitly ● ability to update figures ● installation instructions: https://github.com/matplotlib/jupyter-matplotlib
https://matplotlib.org/3.2.1/gallery/color/colormap_reference.html
Matplotlib Resources ● Matplotlib Tutorials: https://matplotlib.org/tutorials/ ● Matplotlib Gallery: http://matplotlib.org/gallery.html ● Plotting commands summary: http://matplotlib.org/api/pyplot_summary.html
Fun Resource: https://serialmentor.com/dataviz/
Use perceptually uniform colormaps 😲
Don’t cut the vertical axis 😲
https://seaborn.pydata.org/tutorial.html
Break (5 mins)
Version Control with git
Why version control? Nothing that is committed to version control is ever lost We have this record of who made what changes when Version control is the lab notebook of the digital world : it’s what professionals use to keep track of what they’ve done and to collaborate with other people. Every large software development project relies on it, and most programmers use it for their small jobs as well. And it isn’t just for software: books, papers, small data sets, and anything that changes over time or needs to be shared can and should be stored in a version control system https://zuckermanbrain.github.io/git-novice/
Why git specifically? It is fast Work offline - decentralized, everything is on your local machine Can undo mistakes - almost every action in Git only adds data The cool kids are doing it
https://xkcd.com/1597/
Do not copy same code into every data folder 😲
paper_v1_aggressive ... We are slaves to the myopic methods of paper_v0 paper_v1 the previous generation. We seem to share a simultaneously naive ... but nonetheless tenable belief that we Experimental and theoretical methods can “understand” or at least “interpret” and frameworks that have been paper_v1_better how each cell-type processes discarded by vertebrate researchers are information in the fruit fmy optic lobe. still treated with obeisance; ... moving bars do a poor job of revealing the mysteries of V1, but they might just work for fmies; separation of RGCs into binary ON and OFF cells is equivocal at best, but the the fmy eye might just be that simple.
paper_v1_better2_advisor ... After all, how complicated can a fmy eye be? paper_v1_better2 paper_v1_better2_advisor_1 We seem to share a simultaneously naive but nonetheless tenable belief that we can “understand” or at least “interpret” We seem to share a simultaneously naive but how each cell-type processes nonetheless tenable belief that we can “understand” information in the fruit fmy optic lobe. or at least “interpret” how each cell-type processes Experimental and theoretical methods information in the fruit fmy optic lobe. Experimental and frameworks that have been and theoretical methods and frameworks that have discarded by vertebrate researchers are been discarded by vertebrate researchers are still still treated with obeisance; moving bars treated with obeisance; moving bars do a poor job of do a poor job of revealing the mysteries revealing the mysteries of V1, but they might j ust of V1, but they might just work for fmies; work for fmies; separation of RGCs into binary ON separation of RGCs into binary ON and OFF cells is equivocal at best, but the the fmy eye and OFF cells is equivocal at best, but might just be that simple. The allure of an easily the the fmy eye might just be that simple. interpretable framework is too great to resist. After The allure of an easily interpretable all, how complicated can a fmy eye be? framework is too great to resist.
HEAD master git add git commit
HEAD master git add git commit
HEAD master br1 git branch br1 git checkout br1
HEAD master br1 git add git commit
HEAD br1 master git checkout master
br1 HEAD master br2 git branch br2
br1 HEAD master br2 git add git commit
br1 br2 HEAD master git checkout br2
br1 HEAD br2 master git add git commit
br1 master HEAD br2 git add git commit
br1 master HEAD br2 git add git commit
br1 HEAD master br2 git merge br2
br1 HEAD master br2
“Local” version control - keeping it solo git add adds changes in the working directory to the staging area git commit records aka “gives id” to changes git branch br1 creates new branch git checkout br1 switches current workspace to branch “br1” git merge br1 merges br1 into current branch (e.g. master)
git push git pull
Cloning a Repository When you create a repository, it exists as a remote repository. You can clone your repository to create a local copy on your computer and sync between the two locations.
Create a free, private github account https://github.com/join
Git Resources https://zuckermanbrain.github.io/git-novice/ ● Thorough git tutorial (~30 min) http://rogerdudler.github.io/git-guide/ ● Very rough overview (~10 min)
Aside: Extensions to Jupyter Notebook/Lab ● Hinterland - autocompletion while typing 😏 ○ https://jupyter-contrib-nbextensions.readthedocs.io/en/lat est/nbextensions/hinterland/README.html ● Variable inspector - you can see your vars!! 😃 ○ https://jupyter-contrib-nbextensions.readthedocs.io/en/lat est/nbextensions/varInspector/README.html ● Autopep8 - formatting for publishing code documentation 🤔 ○ https://jupyter-contrib-nbextensions.readthedocs.io/en/lat est/nbextensions/code_prettify/README_autopep8.html
HW2 ● Plotting Coronavirus Data ○ JHU data https://data.humdata.org/dataset/novel-coronavirus-2019-ncov-ca ses ○ NYT github repo https://github.com/nytimes/covid-19-data ● Setting up your own github account ● Bonus: create a personal website with github pages https://guides.github.com/features/pages/ ○ https://jekyllthemes.io/theme/online-cv website templates
https://github.com/sharu725/online-cv
Recommend
More recommend