Add unit tests for visualization.py#271
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/conservationtechlab/animl-py/sessions/3a120ebb-643b-4805-bcc8-5aee6f3dadd2 Co-authored-by: tkswanson <4371698+tkswanson@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add unittest for visualization.py
Add unit tests for visualization.py
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No test coverage existed for
src/animl/utils/visualization.py. Addstests/test_visualization.pywith 28 tests covering all three public functions.Test coverage
TestPlotBox(15 tests)min_conffiltering, NaN bbox skippingclassifier_label_colmodes:None,"category", custom columnshow_confidence, customcolors/detector_labels,Nonefallback to defaultsValueErroron missing required columns;FileNotFoundErroron bad pathTestPlotAllBoundingBoxes(9 tests)_box.jpgwritten and readableclassifier_label_col, confidence threshold, custom colors/labelsValueErroron wrongfile_color mismatchedcolors/detector_labelslengthsTestPlotFromFile(4 tests){stem}_{i}_{ext}naming.jpgUses real sample images from
examples/Southwest/, temporary directories with teardown cleanup, andreturn_img=Truethroughout to avoid display windows.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dns.google/usr/bin/python python -c from animl.utils import visualization; print('OK')(dns block)/usr/bin/python python -m pytest tests/test_visualization.py -v(dns block)from pathlib import Path
import csv, tempfile, shutil
from animl.utils import visualization
img = list((Path.cwd() / 'examples' / 'Southwest').glob('*.JPG'))[0]
tmp = tempfile.mkdtemp()
out_dir = Path(tmp) / 'out'
out_dir.mkdir()
rows = [{'filepath': s` (dns block)
img = list((Path.cwd() / 'examples' / 'Southwest').glob('*.JPG'))[0]
tmp = tempfile.mkdtemp()
out_dir = Path(tmp) / 'out'
out_dir.mkdir()
rows = [{'filepath': s` (dns block)
Original prompt
Add unittest for visualization.py
Create a comprehensive unittest for
src/animl/utils/visualization.pyfollowing the existing test patterns in the repository.Context
The
visualization.pymodule contains three main functions that need testing:plot_box()- Plots bounding boxes on imagesplot_all_bounding_boxes()- Processes a manifest and saves images with boxesplot_from_file()- Reads CSV and plots boxesReference the existing visualization.py code here: https://github.com/conservationtechlab/animl-py/blob/371db736daed9b380f33960e5ef32e4c5273907d/src/animl/utils/visualization.py
Requirements
Test File Location
tests/test_visualization.pyTest Structure
Follow the existing test patterns from the repository:
unittestframework (liketests/buow_test.py)@unittest.skipdecorator where appropriate for tests that require external resourcesanimlpackageTests to Include
Test
plot_box()function:Test
plot_all_bounding_boxes()function:Test
plot_from_file()function:Test Data
examples/Southwest/directory (referenced in other tests)filepath,conf,bbox_x,bbox_y,bbox_w,bbox_h,categoryExpected Test Pattern
Code Quality
Additional Notes
return_img=True)Deliverables
tests/test_visualization.pywith comprehensive unittest coverageThe following is the prior conversation context from the user's chat exploration (may be truncated):
Assistant: To test a GUI-based app like MatchyPatchy, you'd typically use a combination of testing strategies. Let me first look at the MatchyPatchy repository to understand its structure and see what testing approach would work best.
Assistant: I found MatchyPatchy! It's a GUI tool for human validation of AI-powered animal re-identification developed by the San Diego Zoo Wildlife Alliance Conservation Technology Lab. Based on the codebase, here's how you can approach testing this GUI application:
Testi...
This pull request was created from Copilot chat.