Testing Python Data Science Code
54mAdvanced2022-09-01
Authors

Miki Tebeka
CEO at 353Solutions
Course details
The larger and more complex the world of data science becomes, the more data there is to collect, sort, clean, model on, and much more. An emerging pain point in this brave new world is that a lot can go wrong if your data engineering and development practices are shoddy. This advanced-level course shows data scientists, Python developers, and data analysts how to test scientific (data science) code written in Python. Veteran data science trainer and consultant Miki Tebeka covers testing techniques, with a focus on issues specific to data science code, such as floating point errors, statistical testing, working with large datasets, choosing a baseline, and more. After presenting a testing overview, Miki dives into testing with pytest and hypothesis. He explains how to use schemas, truth values, approximate testing, and more in data validation. Miki goes over regression testing, then demonstrates how to test Jupyter Notebooks.
Skills covered
PythonProgramming LanguagesOpen SourceSoftware DevelopmentOne-Off
Concepts
Introduction
- Testing scientific applications
- What you should know
- Setting up
Testing Overview
- Why test
- Types of tests
- Challenges in testing scientific applications
- Continuous integration overview
pytest
- pytest overview
- Selecting tests
- Parametrized tests
- Fixtures
- Mocking
- Challenge - Test with pytest
- Solution - Test with pytest
hypothesis
- Overview of hypothesis
- Testing with hypothesis
- NumPy utilities
- pandas utilities
- Writing strategies
- Challenge - Test with hypothesis
- Solution - Test with hypothesis
Data Validation
- Using schemas
- Truth values
- Floating point wonders
- Approximate testing
- Dealing with randomness
- Comparing pandas DataFrames
- Challenge - Testing numerical code
- Solution - Testing numerical code
Regression Testing
- Regression testing overview
- Selecting regression data
- Choosing quality metrics and baseline
- Quality regression testing
- Choosing speed and memory metrics
- Performance regression testing
Testing Jupyter Notebooks
- Testing Notebooks overview
- Using nbconvert
- Refactoring code
- Other test libraries
Conclusion
- Next steps