Skip to content

Latest commit

 

History

History
175 lines (121 loc) · 7.43 KB

2021_11_15_Python.md

File metadata and controls

175 lines (121 loc) · 7.43 KB

Software Carpentries materials

The schedule below was followed during a Software Carpentries Workshop, hosted at the TU Delft in November 2021

Session 1 - Programming with Python Materials

[https://swcarpentry.github.io/python-novice-inflammation/]

Program

12:15 - Organizers/instructors/helpers in the Zoom meeting room to check last set ups, introductions etc

12:30 - Welcome and instructions of the day

  • Reminder Code of Conduct/How to get help
  • Reminder on how to get help
  • Programme of the day
  • Roll call & Ice breaker

12:40 - First 5 mins to check that everybody installed Anaconda and download the datasets swc-python folder on Desktop

$ conda --version
$ python --version
$ jupyter --version

12:45 - Introducing Jupyter (15 min)

13:00 - Python Fundamentals (45 mins)

  • Lesson 1 Variables and type
  • Lesson 4 Lists and slicing
  • Skipped: Nested lists, and append/pop

13:45 - BREAKOUT Session 1 (15 min) Exercises 1 and 2 (open in browser)

14:00 - Coffee break (15 min)

14:15 - Loading and analysing data in Python (30 mins)

  • Lesson 2 (original 60 mins) Import and NumPy and display data (15 mins) Basic statistics on data (10 mins)

14:45 - Visualizing Data (45 mins)

  • Lesson 3 (original 50 mins) Matplotlib (15 mins) Plotting (15 mins) Saving plots (10 min)

15:30 - Coffee break

15:45 - Repeating actions with FOR Loops (45 mins)

  • Lesson 5 (original 30 mins)
  • Lesson 6 (original 20 mins) Introducing For Loops_ Analyzing data from multiple files_

16:30 - BREAKOUT Session 2 (20 min) Exercises 3 and 4 (open in browser)

16:50 - Final questions for the day + reminder feedback
17:00 - End
17:00 - Sharing Feedback Instructors/Helpers

Session 2 - Programming with Python

Program

12:15 - Organizers/instructors/helpers in the Zoom meeting room to check last set ups, introductions etc
12:30 - Start workshop and let participants in! We should not need time to check installations as any remaining problems are addressed on day 3.

12:30 - Welcome and instructions of the day @ Paula

  • Reminder Code of Conduct/How to get help.
  • Programme of the day
  • Ice breaker

12:40 - Recap of Day 2 (5 minutes)
12:45 - Making Choices (20 minutes teaching + 5 minutes exercise)

Plenary Exercises:

  • Plenum: How many paths?

  • Together, inspect all datasets for suspicious data

13:15 - Creating Functions (20 minutes teaching + 5 minutes plenum exercises)

  • Lesson 8 Skipping: Testing and Documentation

Plenary Exercises:

13:35 - Breakout Session 1 (25 min) Exercise 7 (open in browser)

These exercises can also be found on the SWC website:

14:00: Coffee Break I

ADDED part on modular code

  1. Tidying-up
  2. Create script called processing.py
  3. Copy functions (visualize, detect_problems) to script
  4. Create new notebook called inflammation_analysis_refactored.ipynb
  5. Import (visualize, detect_problems) in the new notebook and place in for-loop to analyse for all files
  6. Questions in session:
    a. Do we still need to import numpy and matplotlib when we are importing them in the processing.py script?
    No, this is handled in the script.
    b. What happens to the savefig in the loop?
    Currently, during each loop the file imflammation.png is overwritten. Solution for future sessions: We could add new savenames or leave the savefig out of the functions entirely for simplicity.

Resources on structuring python code:

14:15: Errors and Exceptions (15 minutes teaching + 5 minutes exercise)

Example plenum:

14:40: Defensive Programming (20 min)

  • Lesson 10
  • Example for a pre-condition to find empty array
  • Add precondition to inflammation_analysis.ipynb
  • Skipped: Replace previous conditional statements in inflammation_analysis.ipynb by assertions

Questions during session: a. When would you use assert and when a conditional statement? Assert is used to verify the correct usage and executation of your code. Conditional statements are used to handle choices as part of the code functionality.

15:05: SKIPPED DUE TO LACK OF TIME!

  • Lesson 11 Debugging (20 minutes teaching + 5 minutes exercise)

Exercises:

15:30: Coffee Break II

15:45: Command-Line Programs (45 min)

16:30: Breakout Session 2 (30 min)

  • Exercise 9, 10 and (optional) 11 Solutions are already present in the code folder (use code/reading_06.py as starting point):
    Solution exercise 9: code/reading_08.py
    Solution exercise 10: code/reading_09.py
    Solution exercise 11: code/my_ls.py

16:50 - Wrap up, Questions, etc.
17:00 - End
17:00 - Sharing Feedback Instructors/Helpers