Day 1: Adaptability & Extendibility
* Modularity in python
* DRY
* SOLID
* Design Patterns
Day 2: Testing, Documentation & Readability
* Packaging
* Unit Tests
* Doctest
* Sphinx
* GitLab Integration
Day 3: Performance & Scalability
* Introduction
* Profiling & Benchmarking
* Data, Do's and Dont's
* Ahmdal's law
* Parallelisation with `joblib` and `mpi4py`
A very basic sample package 'bitmap-filter' could look like this
```
<Package bitmap-filter>
├── bitmapfilter
│ └── __init__.py
├── docs
├── LICENSE
├── README.rst
├── setup.py
└── tests
└── __init__.py
```
Optional: requirements.txt for development dependencies (or in setup.py)
LICENSE: Most important file, how can others use your codeREADME.rst (may also be in Markdown format):setup.pysetup.py 1 from setuptools import setup
2
3 setup(
4 name='bitmap-filter',
5 version='0.1.0',
6 description='A sample project for the Python programming course',
7 packages=['bitmap-filter'],
8 cmdclass={},
9 test_suite="tests",
10 install_requires=[],
11 tests_require=[],
12 extras_require={},
13 )

Please pull from the course materials repository:
https://itgit.bs.ptb.de/burger03/python-course-material
Test hierarchy
Often split teams: Development ↔ Testing
Why:
How I:
How II:
pushmergeunittest ILinks: official page good tutorial
1 # module: mymodule_test.py
2 import unittest
3
4 class MyModuleTest(unittest.TestCase):
5 def test_one(self):
6 self.assertEqual(2+2, 4, "The simple addition failed")
7
8 def test_two(self):
9 self.assertLessEqual(2, 3, "2 should be <= 3")
10 self.assertLessEqual(3, 3, "3 should as well be <= 3")
If you want to execute tests stand-alone from CLI, add:
1 if __name__ == '__main__':
2 unittest.main()
unittest IIsetUp, tearDown and setUpClass, tearDownClass unittest.TestSuite@unittest.skipIfpython -m unittest tests/test_something.pypython -m unittest discover -p <TEST_PATTERN>unittest IIIAdd to setup.py:
1 from setuptools import setup
2
3 setup(
4 #...
5 test_suite="tests", # folder containing the unit tests
6 #...
7 )
doctest IExample:
1 def my_add(a: int, b: int) -> int:
2 """
3 Adds two integer numbers.
4
5 :param a: first value
6 :param b: second value
7 :return: int
8
9 Example:
10
11 >>> my_add(1, 2)
12 3
13 >>> my_add(3, 4)
14 7
15 """
16 return a + b
1 def fun() -> int:
2 """Just an example for a single line doc string."""
help(fun) shows docstring in Python Consoledoctest IIPros:
unittest.TestSuiteCons:
doctest IIIdoctests to your unittest.TestSuiteDoctest's unittest API
Just add this snippet to your_module.py or your_module_test.py:
1 import unittest
2 import doctest
3 import yourmodule
4
5
6 def load_tests(loader, tests, ignore):
7 tests.addTests(doctest.DocTestSuite(yourmodule))
8 return tests
Acts as:
Integrations, Plugins (Jira)
CI/CD is a method to frequently deliver apps to customers by introducing automation into the stages of app development. The main concepts attributed to CI/CD are continuous integration, continuous delivery, and continuous deployment. CI/CD is a solution to the problems integrating new code can cause for development and operations teams (AKA "integration hell").
-- Redhat Web Page link
git push and also scheduled.gitlab-ci.yml in YAML syntax.gitlab-ci.ymldefault:
image: <DOCKER_IMAGE_NAME>
stages:
- test
# further stages go here
test:
stage: test
script:
- python3 -m venv venv
# further setup and tests go here
cache:
paths:
- venv
Please pull from the course materials repository:
https://itgit.bs.ptb.de/burger03/python-course-material
Why?:
https://www.writethedocs.org/guide/writing/beginners-guide-to-docs/

How?:
Based on this SO blog
pipconf.py: configure extensions here (cf. exercise)index.rst: entry point and overall layoutPlease pull from the course materials repository:
https://itgit.bs.ptb.de/burger03/python-course-material
Thanks!
| Table of Contents | t |
|---|---|
| Exposé | ESC |
| Presenter View | p |
| Source Files | s |
| Slide Numbers | n |
| Toggle screen blanking | b |
| Show/hide next slide | c |
| Notes | 2 |
| Help | h |