2020-10-20-online

Icebreaker, day 6

Automated testing

https://coderefinery.github.io/testing/

Exercise

https://coderefinery.github.io/testing/pytest/

until xx:42 (let us know if you need more time)

goal: run the test using pytest, then break it and test again

extra: try the pre-commit hook exercise as well (but we will also show this part in the main room)

Statusupdates:

Break

:::danger until xx:04 :::

Github actions

https://coderefinery.github.io/testing/gh-actions/

Exercise

https://coderefinery.github.io/testing/gh-actions/ until xx:34

goal: up to step 4, or as far as you get

breakoutroom status updates:

Room 7: around step 5

Room 10/11: Step 5 for half the group

room 6: at step 5

Main room/stream:

room 15:

room 1:

room 4:

room 8:

Room 12:

Break

:::danger until xx:51 (you may go to your breakoutroom and say goodbye, since there will be no more breakoutrooms during the remainder of the workshop) :::

Modular code development

https://github.com/coderefinery/modular-type-along

What is modular code development for you?

Your best practices to get readable/modular code?

Questions

Steps done in example, based on your suggestions below

  1. version control setup with git (remember to commit)
  2. .mean() from pandas library (using library)
  3. functionalize reading the csvfile
    • add arguments (making the function more general)
      • num_measurements
      • csvfilename (adding csv to make sure that the input file should be a csv)
      • key (which temperature to read from file)
    • rename function to describe what it does
    • rename variables to be more general: temperature -> column
  4. functionalize plotting and saving results from above into png plot
    • add arguments
      • temperatures (result from above)
      • avgtemperature
      • outputfilename
  5. for all new functions, create functional arguments such as key=’Air temperature (degC)’
  6. docstrings for the functions
  7. for loop around the functions for different number of measurements
    • output filenaming with adaptive naming
  8. add if __name__ == '__main__': main() and create main function around other functions
  9. parsing arguments via commandline (eg sys.argv or argparse or click (used in the example in material); the latter libraries also enable running the script with python evaluation.py --help to get information on which arguments are needed) -> no need to interact with the code anymore

Suggestions for next steps for the example

Feedback

please give feedback below, one positive thing and something we can improve on