Skip to content

Add additional tests for find_annotation_position_inside_polygon - #127

Open
ShivamRajSri wants to merge 1 commit into
brainglobe:mainfrom
ShivamRajSri:add-polygon-tests
Open

Add additional tests for find_annotation_position_inside_polygon#127
ShivamRajSri wants to merge 1 commit into
brainglobe:mainfrom
ShivamRajSri:add-polygon-tests

Conversation

@ShivamRajSri

Copy link
Copy Markdown

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Additional unit tests for find_annotation_position_inside_polygon.

Why is this PR needed?

The function find_annotation_position_inside_polygon contains several edge-case behaviors described in the docstring, such as:

  • handling polygons with insufficient vertices
  • working with concave polygons
  • repairing invalid/self-intersecting polygons using buffer(0)
  • resolving geometries that may become MultiPolygon

Currently these behaviors were not fully tested. Adding these tests improves reliability and helps prevent regressions in future changes.

What does this PR do?

This PR adds additional unit tests in:

tests/test_unit/test_find_annotation_position_inside_polygon.py

The new tests cover:

  • polygons with fewer than 4 vertices returning None
  • a simple convex polygon where the annotation point is near the expected center
  • concave polygons where the centroid lies outside the geometry
  • self-intersecting polygons that are repaired using buffer(0)
  • verification that the returned annotation point lies inside the repaired geometry

These tests improve coverage of the polygon annotation helper function and validate behavior described in the function’s documentation.


References

No related issue.
Tests were added to improve coverage and validate documented edge cases.


How has this PR been tested?

The new tests were executed locally using:

pytest tests/test_unit/test_find_annotation_position_inside_polygon.py -v

All tests pass locally. Existing tests were also run to ensure that no current functionality is affected.

Pre-commit hooks were run to ensure formatting and linting compliance.


Is this a breaking change?

No.

This PR only adds tests and does not modify any existing functionality.


Does this PR require an update to the documentation?

No.

This PR only adds unit tests and does not introduce any new functionality or change existing behavior.


Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@codecov

codecov Bot commented Mar 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.63%. Comparing base (9f8422b) to head (620c791).
⚠️ Report is 20 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #127   +/-   ##
=======================================
  Coverage   69.63%   69.63%           
=======================================
  Files           5        5           
  Lines         326      326           
=======================================
  Hits          227      227           
  Misses         99       99           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant