Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample-volume summary

This repository contains a small utility used to summarize laboratory sample volumes. Its default execution path works, and the initial tests pass, but that does not mean every possible path is correct.

Your task is to use mypy and pytest together to find and fix two different problems.

Set up

Create or activate a Python environment and install the development tools:

python -m pip install -r requirements-dev.txt

Establish the baseline

Run the program and the existing tests:

python sample_summary.py
python -m pytest

Both should succeed. They currently exercise only the default data and a typical tolerance value.

Now run the static type checker:

python -m mypy .

Read each diagnostic before changing the code. Determine which message concerns a missing function annotation and which concerns a value that does not match a declared return type.

Add the missing tests

Extend tests/test_sample_summary.py with a test expressing this requirement:

  • A measured value exactly one tolerance away from its target is accepted. For example, 9.5 is within a tolerance of 0.5 around 10.0.

Run pytest again. The new tests should expose behavior that the initial tests missed.

Fix the implementation

Fix sample_summary.py so that:

  • every function has a simple, accurate type signature;
  • CSV text is converted to floating-point values;
  • the tolerance comparison includes its boundary.

Verify and submit

Run the same checks again:

python -m pytest
python -m mypy .

Inspect and commit your changes:

git diff
git status
git add sample_summary.py tests/test_sample_summary.py
git commit -m "Validate sample volumes with tests and types"
gh student submit

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages