Repository navigation
Description
Student: Pruthviraj Gojare
Task: R23-T050 · 10 of 10
Repository: https://github.com/S-AI-Projects/TheAlgorithms-Python
Assigned working branch: student/e26b07f0834
Goal
CONTRIBUTING.md asks for doctests covering both valid and erroneous input. Bring digital_image_processing/filters/laplacian_filter.py (1 doctests today) up to that standard. Only 1 doctest. Write doctests using small numpy arrays (no image files) for each kernel size and for the error path.
Steps
- Run
uv run --python 3.12 --with numpy --with opencv-python-headless --with pytest --with pytest-cov pytest digital_image_processing/filters/laplacian_filter.py --cov=digital_image_processing/filters --cov-report=term-missingand note which lines of this file are not covered. - For each public function (
my_laplacian), list valid, boundary and invalid inputs. - Add doctests for every uncovered branch and at least one erroneous input per function (showing the Traceback/exception line).
- Run
uv run python -m doctest -von the file and paste the summary line. - Make the code change in the repository: digital_image_processing/filters/laplacian_filter.py: doctests on small numpy arrays for each kernel size (1, 3, 5, 7) and the error path. Re-run the automated check and the repo's own tests afterwards.
- Prepare the PR: on branch R23-T050, commit the code change plus your work/R23-T050/ evidence, put your findings in the PR description and open the PR against the org fork. For a later upstream PR, create a second branch containing only the code change (no work/ folder).
Done when
☐ digital_image_processing/filters/laplacian_filter.py doctests rise from 1 to cover ksize 1, 3, 5 and 7 on small numpy arrays (no image files) and an invalid ksize (ValueError: ksize must be in (1, 3, 5, 7)).
☐ Doctests run with uv run --python 3.12 --with numpy --with opencv-python-headless --with pytest pytest <file> (output pasted).
☐ Coverage of my_laplacian is 100%.
Additional task guidance
Additional curated task guidance
Item:
digital_image_processing/filters/laplacian_filter.py (81 lines; 1 doctests)
Task type:
Doctest completeness
Code change (goes into the PR):
digital_image_processing/filters/laplacian_filter.py: doctests on small numpy arrays for each kernel size (1, 3, 5, 7) and the error path.
Automated check:
uv run --python 3.12 --with numpy --with opencv-python-headless --with pytest --with pytest-cov pytest digital_image_processing/filters/laplacian_filter.py --cov=digital_image_processing/filters --cov-report=term-missing # report shows 100% (or justified) for this file
Prerequisites:
Linux/WSL2/Codespaces with uv (https://docs.astral.sh/uv/getting-started/installation/); run uv sync --group=test once – it installs the Python version CI uses (.python-version = 3.15t) and the test dependencies, about 1–2 GB; files importing cv2 need uv run --python 3.12 --with numpy --with opencv-python-headless … because CI skips digital_image_processing/ (no 3.15t wheel)
Upstream PR rules:
Follow CONTRIBUTING.md: type hints on every parameter/return, doctests for valid and erroneous input, snake_case file names, no duplicate of an existing implementation, no hand edits to DIRECTORY.md. CI (pytest with doctests, ruff) must pass – bots close PRs without tests or type hints. Keep work/ (benchmarks, notes, property tests) out of the upstream branch; put results in the PR description.
Source (pinned):
https://github.com/TheAlgorithms/Python/blob/574d100b7181956e9c8384552fd078165e4cc326/digital_image_processing/filters/laplacian_filter.py
Change:
No change recorded
PR destination:
Preserved pilot guidance
Submission checklist
- Complete this task and its checks.
- Add the required evidence and link your pull request here.
- Select this S-AI-Projects fork as the PR base repository.
- Request instructor review.
Keep this PR focused on this task. Do not submit assignment PRs to the upstream repository.
Activity