Lecture 2 - HW1,numpy arrays, matplotlib, and git 2020.4.14 Review - - PowerPoint PPT Presentation

lecture 2 hw1 numpy arrays matplotlib and git
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Lecture 2 - HW1,numpy arrays, matplotlib, and git

2020.4.14

slide-2
SLIDE 2

Review of Python Basics from Lecture 1

slide-3
SLIDE 3

Topics from Lecture 1

Lists Dicts (Tuples,) {sets} Strings, ints, floats Objects, attributes, methods Functions Importing .py files/libraries

slide-4
SLIDE 4

slides, hws, solutions are posted here: neuropython.com/calendar

slide-5
SLIDE 5

Recorded zoom lectures will be accessible via courseworks (more fun in real time though)

slide-6
SLIDE 6

HW1 Solutions

slide-7
SLIDE 7
slide-8
SLIDE 8
slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12
slide-13
SLIDE 13
slide-14
SLIDE 14
slide-15
SLIDE 15
slide-16
SLIDE 16
slide-17
SLIDE 17
slide-18
SLIDE 18
slide-19
SLIDE 19
slide-20
SLIDE 20
slide-21
SLIDE 21
slide-22
SLIDE 22
slide-23
SLIDE 23
slide-24
SLIDE 24
slide-25
SLIDE 25
slide-26
SLIDE 26
slide-27
SLIDE 27
slide-28
SLIDE 28
slide-29
SLIDE 29
slide-30
SLIDE 30
slide-31
SLIDE 31
slide-32
SLIDE 32

Numpy Arrays (see slides)

slide-33
SLIDE 33

Plotting with Matplotlib (see slides)

slide-34
SLIDE 34

%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
slide-35
SLIDE 35

https://matplotlib.org/3.2.1/gallery/color/colormap_reference.html

slide-36
SLIDE 36

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

slide-37
SLIDE 37

Fun Resource: https://serialmentor.com/dataviz/

slide-38
SLIDE 38

Use perceptually uniform colormaps 😲

slide-39
SLIDE 39

Don’t cut the vertical axis 😲

slide-40
SLIDE 40

https://seaborn.pydata.org/tutorial.html

slide-41
SLIDE 41

Break (5 mins)

slide-42
SLIDE 42
slide-43
SLIDE 43

Version Control with git

slide-44
SLIDE 44
slide-45
SLIDE 45

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/

slide-46
SLIDE 46

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

slide-47
SLIDE 47

https://xkcd.com/1597/

slide-48
SLIDE 48
slide-49
SLIDE 49
slide-50
SLIDE 50

Do not copy same code into every data folder 😲

slide-51
SLIDE 51

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.

slide-52
SLIDE 52

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

slide-53
SLIDE 53

git add git commit

HEAD master

slide-54
SLIDE 54

git add git commit

HEAD master

slide-55
SLIDE 55

HEAD master

git branch br1 git checkout br1

br1

slide-56
SLIDE 56

master br1 HEAD

git add git commit

slide-57
SLIDE 57

master

git checkout master

br1 HEAD

slide-58
SLIDE 58

master br1 HEAD

git branch br2

br2

slide-59
SLIDE 59

master br1 HEAD

git commit git add

br2

slide-60
SLIDE 60

br1

git checkout br2

br2 master HEAD

slide-61
SLIDE 61

br1

git add

br2 master HEAD

git commit

slide-62
SLIDE 62

br1

git add

master

git commit

br2 HEAD

slide-63
SLIDE 63

br1

git add

master

git commit

br2 HEAD

slide-64
SLIDE 64

br1 br2 master HEAD

git merge br2

slide-65
SLIDE 65

br1 br2 master HEAD

slide-66
SLIDE 66

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)

slide-67
SLIDE 67

git push git pull

slide-68
SLIDE 68
slide-69
SLIDE 69
slide-70
SLIDE 70

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

slide-71
SLIDE 71
slide-72
SLIDE 72
slide-73
SLIDE 73
slide-74
SLIDE 74
slide-75
SLIDE 75
slide-76
SLIDE 76
slide-77
SLIDE 77
slide-78
SLIDE 78
slide-79
SLIDE 79

Create a free, private github account

https://github.com/join

slide-80
SLIDE 80

Git Resources

https://zuckermanbrain.github.io/git-novice/

  • Thorough git tutorial (~30 min)

http://rogerdudler.github.io/git-guide/

  • Very rough overview (~10 min)
slide-81
SLIDE 81

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

slide-82
SLIDE 82
slide-83
SLIDE 83

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

slide-84
SLIDE 84

https://github.com/sharu725/online-cv