Numpy, pylab, matplotlib (follow-up)

Slides:



Advertisements
Similar presentations
COMPUTER PROGRAMMING Task 1 LEVEL 6 PROGRAMMING: Be able to use a text based language like Python and JavaScript & correctly use procedures and functions.
Advertisements

More on Dynamic Memory Allocation Seokhee Jeon Department of Computer Engineering Kyung Hee University 1 Illustrations, examples, and text in the lecture.
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
Python plotting for lab folk Only the stuff you need to know to make publishable figures of your data. For all else: ask Sourish.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
COMP 171: Principles of Computer Science I John Barr.
OSP Tutorial An Introduction. Getting to OSP  Obtain a CSE account  Recommend xming to remote log in from USF Website 
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Programming for GCSE 1.0 Beginning with Python T eaching L ondon C omputing Margaret Derrington KCL Easter 2014.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 4: Writing programs.
Practical Kinetics Exercise 0: Getting Started Objectives: 1.Install Python and IPython Notebook 2.print “Hello World!”
CS112: Course Overview George Mason University. Today’s topics Go over the syllabus Go over resources – Marmoset – Blackboard – Piazza – Textbook Highlight.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Introduction to python programming
Introduction to python
PH2150 Scientific Computing Skills
Development Environment
Topic: Python’s building blocks -> Variables, Values, and Types
A Playful Introduction to Programming by Jason R. Briggs
Topic: Programming Languages and their Evolution + Intro to Scratch
Introduction to Eclipse
CMSC201 Computer Science I for Majors Lecture 13 – Midterm Review
Intro to Python Programming – Part II
PH2150 Scientific Computing Skills
IPYTHON AND MATPLOTLIB Python for computational science
CMSC201 Computer Science I for Majors Lecture 13 – Midterm Review
Engineering Innovation Center
Prepared by Kimberly Sayre and Jinbo Bi
CS190/295 Programming in Python for Life Sciences: Lecture 1
PH2150 Scientific Computing Skills
Introduction to Python programming
Sussex Neuroscience Coding Club title slide
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Learning to Program in Python
How to Run a Java Program
Introduction to Algorithm Design
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
Using Mach153A Lecture Tools
Teaching London Computing
Tonga Institute of Higher Education
Decision Structures and Indefinite Loops
Introduction to Dictionaries
Linked Lists in C and C++
Accelerated Introduction to Computer Science
Homework #5 — Monte Carlo Simulation
Elements of a Python Program
More About Functions Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
Variables, Lists, and Objects
Debuggers and Debugging
Simple Graphics Package
Objects (again) Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An Introduction.
More elements of Python programs
Notes on pyplot Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An Introduction.
How to Improve Releasing Efficiency via i18N/L10n Test Automation.
Notes about Homework #4 Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming:
CSV files Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An Introduction.
Note on Program Design Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming:
Notes on Homework #6 Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
CS 1111 Introduction to Programming Spring 2019
CMSC201 Computer Science I for Majors Final Exam Information
Windows Installation Tutorial
Lab Project #4: PerfLab— Code Optimizations and Performance
Chapter 1: Programming Basics, Python History and Program Components
Introduction to Python
The Python interpreter
EN Software Carpentry Python – A Crash Course Esoteric Sections Compiled Languages.
CMSC 202 Exceptions 2nd Lecture.
CMSC201 Computer Science I for Majors Lecture 12 – Midterm Review
Presentation transcript:

Numpy, pylab, matplotlib (follow-up) Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An Introduction to Computer Science, 2nd edition, by John Zelle and copyright notes by Prof. George Heineman of Worcester Polytechnic Institute) CS-1004, A-Term 2014 Numpy, pylab, matplotlib

Follow-up from Prof. Heineman Lecture notes from Friday are here:– http://www.tinyurl.com/guest-1004 Link also on course website (under Lecture Notes) Useful stuff at end of notes, beyond what he covered in lecture Read especially, §1.7, §1.8 Try the “Debugging Challenge” §1.8 Questions on quizzes like this CS-2301, D-Term 2014 Introduction

Follow-up from Prof. Heineman (continued) Pylab Another way of accessing matplotlib I.e., a .py script:– from matplotlib.pylab import * import matplotlib.pylab __doc__ = matplotlib.pylab.__doc__ matplotlib.pylab is a longer script Containing # provide the recommended moduleabbrevs in # the pylab namespace import matplotlib.pyplot as plt import numpy as np import numpy.ma as ma Is anyone still having trouble installing matplotlib? CS-2301, D-Term 2014 Introduction

Follow-up from Prof. Heineman — numpy Principal class is ‘array’ Somewhat like lists but, Multiple dimensions Different way of indexing 2nd and subsequent dimensions More efficient internally Tutorial: http://wiki.scipy.org/Tentative_NumPy_Tutorial Check it out Much will be over your head now More useful after end of course CS-2301, D-Term 2014 Introduction

Numpy and arrays — Example L = [1, 2, 3, 4, 5] M = [] N = [] P = [] for x in L: M.append(x*x) N.append(sqrt(x)) P.append(2**x) Q = [L, M, N, P] Q1 = numpy.array(Q) With Python lists Q[2][3] With numpy arrays Q1[2, 3] CS-2301, D-Term 2014 Introduction

Questions? CS-2301, D-Term 2014 Introduction

Follow-up from Prof. Heineman — “Compile often!” What does this mean? Especially since Python is an interpretive language? Example:– typing code into Python shell Errors show up (almost) immediately Example:– typing into a module When do errors show up? What does “Run module” menu command do? Resets shell (Virtually) “types” content of module into shell As if you typed it yourself! Picks up some errors … … as interpreter But some errors cannot be caught until you actually call the function! CS-2301, D-Term 2014 Introduction

Additional advice — “Test often” Example 1 — Homework #2 Q3 asks you to print out information for each term Why? Answer:– so you can see that it is working correctly! How many had it working the first time you tried it? Q6 asks you to use the function you developed in Q3 100 times (or more) What about all those lines of debug output? Options:– Comment out the print lines Copy Q3 function to Q6 function with new name Remove or comment out print lines Write a separate test program or function CS-2301, D-Term 2014 Introduction

Example — Pong Separate into two parts Physics part:– Physics of the motion Display in window Physics part:– Motion in each dimension is independent of other dimension Function:– move1D(pos, vel, uBound, lBound) Returns new positions, accounting for bouncing off edges Testing physics part:– Set up some (artificial) parameters In a loop, call move1D(), get and print new position, use for next call Examine manually CS-2301, D-Term 2014 Introduction

Questions? CS-2301, D-Term 2014 Introduction