data-morph
data-morph copied to clipboard
Optimize `LineCollection`
As requested in https://github.com/stefmolin/data-morph/pull/198#discussion_r1685782050, this is now a separate PR.
Describe your changes
- remove
LineCollection._distance_point_to_linemethod 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
LineCollectioninitializer raise aValueErrorif any of the lines is actually a point (i.e.start == end) and add a test for it
Checklist
- [x] Test cases have been modified/added to cover any code changes.
- [x] Docstrings have been modified/created for any code changes.
- [x] All linting and formatting checks pass (see the contributing guidelines for more information).
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 98.41%. Comparing base (
51b8d26) to head (36d6c94). Report is 14 commits behind head on main.
Additional details and impacted files
@@ 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%) |
:arrow_down: |
| tests/shapes/bases/test_line_collection.py | 100.00% <100.00%> (ø) |