Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize LineCollection #206

Merged

Conversation

JCGoran
Copy link
Contributor

@JCGoran JCGoran commented Jul 22, 2024

As requested in #198 (comment), this is now a separate PR.

Describe your changes

  • remove LineCollection._distance_point_to_line method as it's not used anywhere anymore
  • use numpy vectorized ops when calling LineCollection.distance, resulting in about 100M less function calls for the star shape
  • (subject to change) make LineCollection initializer raise a ValueError if any of the lines is actually a point (i.e. start == end) and add a test for it

Checklist

  • Test cases have been modified/added to cover any code changes.
  • Docstrings have been modified/created for any code changes.
  • All linting and formatting checks pass (see the contributing guidelines for more information).

@github-actions github-actions bot added testing Relating to the testing suite shapes Work relating to shapes module labels Jul 22, 2024
Copy link

codecov bot commented Jul 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.41%. Comparing base (51b8d26) to head (36d6c94).
Report is 14 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #206      +/-   ##
==========================================
- Coverage   98.42%   98.41%   -0.01%     
==========================================
  Files          43       43              
  Lines        1775     1766       -9     
  Branches      358      357       -1     
==========================================
- Hits         1747     1738       -9     
  Misses         25       25              
  Partials        3        3              
Files with missing lines Coverage Δ
src/data_morph/shapes/bases/line_collection.py 91.89% <100.00%> (-0.42%) ⬇️
tests/shapes/bases/test_line_collection.py 100.00% <100.00%> (ø)

@stefmolin stefmolin added this to the 0.3.0 milestone Jul 22, 2024
Copy link
Owner

@stefmolin stefmolin left a comment

Choose a reason for hiding this comment

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

Thank you for pulling this out from the other PR, @JCGoran.

src/data_morph/shapes/bases/line_collection.py Outdated Show resolved Hide resolved
src/data_morph/shapes/bases/line_collection.py Outdated Show resolved Hide resolved
src/data_morph/shapes/bases/line_collection.py Outdated Show resolved Hide resolved
src/data_morph/shapes/bases/line_collection.py Outdated Show resolved Hide resolved
src/data_morph/shapes/bases/line_collection.py Outdated Show resolved Hide resolved
src/data_morph/shapes/bases/line_collection.py Outdated Show resolved Hide resolved
tests/shapes/bases/test_line_collection.py Outdated Show resolved Hide resolved
Copy link
Owner

@stefmolin stefmolin left a comment

Choose a reason for hiding this comment

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

I reworked the distance method to improve naming and cleaned up a few parts.

@stefmolin stefmolin merged commit 8c208e3 into stefmolin:main Aug 29, 2024
19 checks passed
@stefmolin stefmolin linked an issue Aug 30, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shapes Work relating to shapes module testing Relating to the testing suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance improvements for line shapes
2 participants