Skip to content

Update convert shapes to use image class#111

Merged
joshqsumner merged 13 commits intomainfrom
convert_shapes-image-class
Apr 3, 2026
Merged

Update convert shapes to use image class#111
joshqsumner merged 13 commits intomainfrom
convert_shapes-image-class

Conversation

@k034b363
Copy link
Copy Markdown
Contributor

@k034b363 k034b363 commented Mar 26, 2026

Describe your changes
This PR updates several functions to use the new GEO image class instead of a spectral object. The following functions needed to be bundled because of overlap in helper usage:
class.InteractiveShapes
convert.points
convert.shapes
convert.to_roi
transform_polygons
_helpers._transform_geojson_crs

Type of update

  • New feature or feature enhancement

Associated issues
Addresses part of #110

For the reviewer
See this page for instructions on how to review the pull request.

  • PR functionality reviewed in a Jupyter Notebook
  • All tests pass
  • Test coverage remains 100%
  • Documentation tested
  • New documentation pages added to plantcv-geospatial/mkdocs.yml
  • Changes to function input/output signatures added to changelog.md
  • Code reviewed
  • PR approved

@deepsource-io
Copy link
Copy Markdown

deepsource-io Bot commented Mar 26, 2026

DeepSource Code Review

We reviewed changes in 5e7176f...4d919da on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Coverage  

Code Review Summary

Analyzer Status Updated (UTC) Details
Python Apr 3, 2026 4:03p.m. Review ↗
Test coverage Apr 3, 2026 4:04p.m. Review ↗

Code Coverage Summary

Language Line Coverage (New Code) Line Coverage (Overall)
Aggregate
100%
100%
Python
100%
100%

➟ Additional coverage metrics may have been reported. See full coverage report ↗

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates several geospatial conversion/transform utilities from using plantcv.Spectral_data.metadata[...] to the new plantcv.geospatial.images.GEO interface (.crs, .transform, .thumb) and updates tests/docs accordingly as part of the broader Image/GEO/DSM migration (Issue #110).

Changes:

  • Update transform_polygons, convert.points, convert.shapes, convert.to_roi, and _helpers._transform_geojson_crs to use GEO attributes (img.crs, img.transform, img.thumb).
  • Update test fixtures/usages to load a pickled GEO object instead of a pickled Spectral_data object.
  • Update docs to reference GEO and use img.thumb in examples; add dill dependency.

Reviewed changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
plantcv/geospatial/transform_polygons.py Switch from img.metadata["transform"] to img.transform.
plantcv/geospatial/_helpers.py Switch CRS comparison/transform to img.crs.
plantcv/geospatial/convert/points.py Use img.transform/img.crs for geojson IO.
plantcv/geospatial/convert/shapes.py Use img.transform/img.crs for geojson IO.
plantcv/geospatial/convert/to_roi.py Update docs/types and draw ROIs on img.thumb.
plantcv/geospatial/create_shapes/interactive_shapes.py Display img.thumb in Napari viewer instead of img.pseudo_rgb.
tests/test_geospatial_transform_polygons.py Load GEO from pickle and relax assertions.
tests/test_geospatial_helpers.py Load GEO from pickle; assert CRS via img.crs.
tests/create_shapes/test_geospatial_interactive_shapes.py Load GEO from pickle in InteractiveShapes tests.
tests/convert/test_geospatial_to_roi.py Load GEO from pickle; change/relax ROI contour assertions.
tests/convert/test_geospatial_shapes.py Load GEO from pickle; use img.thumb for viewer image.
tests/convert/test_geospatial_points.py Load GEO from pickle; use img.thumb for viewer image.
tests/conftest.py Add geo_pickled/dsm_pickled testdata paths and update comments.
docs/to_roi.md Update parameter description to GEO (but introduces an API reference mismatch).
docs/convert_shapes.md Update parameter docs to GEO and example to img.thumb.
docs/convert_points.md Update parameter docs to GEO.
docs/InteractiveShapes.md Update parameter docs to GEO (but introduces markdown formatting issue).
pyproject.toml Add dill dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/conftest.py Outdated
Comment thread docs/InteractiveShapes.md Outdated
Comment thread docs/to_roi.md Outdated
Comment thread pyproject.toml
Comment on lines 20 to 25
"rasterstats",
"joblib",
"netCDF4",
"altair < 6"
"altair < 6",
"dill"
]
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dill is only imported/used in the test suite, but it's being added to the package's required runtime dependencies. This forces all library users to install dill even when they don't run tests. Consider moving dill to [project.optional-dependencies].test (or switching the fixtures back to stdlib pickle/joblib) so the core install remains minimal.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_geospatial_transform_polygons.py Outdated
Comment thread tests/test_geospatial_transform_polygons.py Outdated
Comment thread tests/convert/test_geospatial_to_roi.py Outdated
Comment thread tests/convert/test_geospatial_to_roi.py Outdated
@joshqsumner joshqsumner self-requested a review April 3, 2026 15:47
Copy link
Copy Markdown
Contributor

@joshqsumner joshqsumner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!

@joshqsumner joshqsumner merged commit fe4aa8c into main Apr 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants