Filtering range options#1949
Conversation
|
|
Overall Grade |
Security Reliability Complexity Hygiene Coverage |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Python | Jul 10, 2026 9:54p.m. | Review ↗ | |
| Code coverage | Jul 10, 2026 9:54p.m. | Review ↗ |
Code Coverage Summary
| Language | Line Coverage (New Code) | Line Coverage (Overall) |
|---|---|---|
| Aggregate | 100% [✓ above threshold] |
100% |
| Python | 100% [✓ above threshold] |
100% |
➟ Additional coverage metrics may have been reported. See full coverage report ↗
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
There was a problem hiding this comment.
Pull request overview
This PR enhances plantcv.filters.obj_props to support range-based filtering modes (cut_side="in" and cut_side="out") so callers can filter objects within/outside a threshold range in a single pass (avoiding repeated regionprops computation).
Changes:
- Added
cut_sideoptions"in"and"out"with tuple-basedthreshvalidation. - Refactored filtering decision into a helper function (
_apply_cut_side). - Updated documentation and expanded unit tests for the new modes and parameter validation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/plantcv/filters/test_filter_objs.py | Adds tests for "in"/"out" modes and new invalid-parameter cases. |
| plantcv/plantcv/filters/obj_props.py | Implements "in"/"out" range filtering and routes comparisons through _apply_cut_side. |
| docs/filters_obj_props.md | Documents the new range-based filtering options and tuple thresh behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| elif cut_side == "in": | ||
| gray_val = 255 if val > min(thresh) or val < max(thresh) else 0 |
| filtered_mask = obj_props(bin_img=mask, cut_side="in", thresh=(0.1, 0.6), regprop="solidity") | ||
| _, nobjs = create_labels(mask=filtered_mask) | ||
| assert nobjs == 20 |
|
|
||
| Calculates properties of objects in a binary image. | ||
| Keeps objects that are either above or below a specified threshold for a specified property. | ||
| Keeps objects that are either above, below, within, or between a specified threshold for a specified property. |
Describe your changes
Adds "in" and "out" modes for
pcv.filters.obj_propswhich use a tuple for the thresh. Currently you could call it twice but sometimes calculating the regionprops is relatively slow so I'd rather be able to do the filtering in one step.Type of update
This is a feature enhancement
Associated issues
None
Additional context
See 5/08/2026 dev meeting notes
For the reviewer
See this page for instructions on how to review the pull request.
plantcv/mkdocs.ymlupdating.md