Lecture 2 - HW1,numpy arrays, matplotlib, and git 2020.4.14 Review - - PowerPoint PPT Presentation
Lecture 2 - HW1,numpy arrays, matplotlib, and git 2020.4.14 Review - - PowerPoint PPT Presentation
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
Review of Python Basics from Lecture 1
Topics from Lecture 1
Lists Dicts (Tuples,) {sets} Strings, ints, floats Objects, attributes, methods Functions 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 inline
- sends png to browser
- no panning or zooming
- new figure for each cell
- no changes to previous figures
%matplotlib notebook
- interactivity in old notebook
- doesn't work in jupyter lab
- need to create separate figures
- ability to update 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 😲
We seem to share a simultaneously naive but nonetheless tenable belief that we can “understand” or at least “interpret” how each cell-type processes information in the fruit fmy optic lobe.
paper_v0
... Experimental and theoretical methods and frameworks that have been discarded by vertebrate researchers are still treated with obeisance;
paper_v1 paper_v1_aggressive
... We are slaves to the myopic methods of the previous generation.
paper_v1_better
... 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.
We seem to share a simultaneously naive but nonetheless tenable belief that we can “understand” or at least “interpret” how each cell-type processes information in the fruit fmy optic lobe. Experimental and theoretical methods and frameworks that have been discarded by vertebrate researchers are still treated with obeisance; moving bars do a poor job of revealing the mysteries
- f 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. The allure of an easily interpretable framework is too great to resist.
paper_v1_better2
... After all, how complicated can a fmy eye be?
paper_v1_better2_advisor
We seem to share a simultaneously naive but nonetheless tenable belief that we can “understand”
- r at least “interpret” how each cell-type processes
information in the fruit fmy optic lobe. Experimental and theoretical methods and frameworks that have been discarded by vertebrate researchers are 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. The allure of an easily interpretable framework is too great to resist. After all, how complicated can a fmy eye be?
paper_v1_better2_advisor_1
git add git commit
HEAD master
git add git commit
HEAD master
HEAD master
git branch br1 git checkout br1
br1
master br1 HEAD
git add git commit
master
git checkout master
br1 HEAD
master br1 HEAD
git branch br2
br2
master br1 HEAD
git commit git add
br2
br1
git checkout br2
br2 master HEAD
br1
git add
br2 master HEAD
git commit
br1
git add
master
git commit
br2 HEAD
br1
git add
master
git commit
br2 HEAD
br1 br2 master HEAD
git merge br2
br1 br2 master HEAD
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”
“Local” version control - keeping it solo
git merge br1 merges br1 into current branch (e.g. master)
git push git pull
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.
Cloning a Repository
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