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

Added linesort two-op operation #266

Merged
merged 14 commits into from
Jun 8, 2021
Merged

Added linesort two-op operation #266

merged 14 commits into from
Jun 8, 2021

Conversation

tatarize
Copy link
Contributor

@tatarize tatarize commented May 6, 2021

Description

Adds in a flag for the linesort command to perform two-opt global distance minimization.

Checklist

  • feature/fix implemented
  • code formatting ok (black and isort)
  • mypy vpype vpype_cli tests returns no error
  • tests added/updated and pytest succeeds
  • documentation added/updated
    • command docstring and option/argument help
    • README.md updated (Feature Overview)
    • CHANGELOG.md updated
    • RTD doc updated and building with no error (make clean && make html in docs/)

@tatarize
Copy link
Contributor Author

tatarize commented May 6, 2021

vpype -v read test.svg linemerge linesort write t1.svg

INFO:root:executing layer processor `linesort` on layer 1 (kwargs: {'no_flip': False, 'two_opt': False})
INFO:root:LineIndex: creating index for 300 lines
INFO:root:LineIndex: creating index for 118 lines
INFO:root:optimize: reduced pen-up (distance, mean, median) from (12750.22643475841, 42.500754782528034, 6.245283127143871) to (5950.841189588275, 19.83613729862758, 4.844412759507364)
INFO:root:layer processor `linesort` execution complete (0.080s)
INFO:root:executing layer processor `linesort` on layer 1337 (kwargs: {'no_flip': False, 'two_opt': False})
INFO:root:LineIndex: creating index for 14 lines
INFO:root:optimize: reduced pen-up (distance, mean, median) from (29.859837039708502, 2.1328455028363216, 1.8746727230260916) to (23.38916720601566, 1.67065480042969, 1.8746727230260916)
INFO:root:layer processor `linesort` execution complete (0.004s)
INFO:root:executing layer processor `linesort` on layer 13379 (kwargs: {'no_flip': False, 'two_opt': False})
INFO:root:LineIndex: creating index for 14 lines
INFO:root:optimize: reduced pen-up (distance, mean, median) from (29.859837039708523, 2.132845502836323, 1.8746727230260958) to (23.389167206015713, 1.6706548004296937, 1.8746727230260958)
INFO:root:layer processor `linesort` execution complete (0.005s)

12750.22643475841 -> 5950.841189588275 in 0.080s

vpype -v read test.svg linemerge linesort -t write t1.svg

INFO:root:executing layer processor `linesort` on layer 1 (kwargs: {'two_opt': True, 'no_flip': False})
INFO:root:optimize: reduced pen-up (distance, mean, median) from (12750.22643475841, 42.500754782528034, 6.245283127143871) to (5361.155188942335, 17.87051729647445, 4.890580975063153)
INFO:root:layer processor `linesort` execution complete (6.169s)
INFO:root:executing layer processor `linesort` on layer 1337 (kwargs: {'two_opt': True, 'no_flip': False})
INFO:root:optimize: reduced pen-up (distance, mean, median) from (29.859837039708502, 2.1328455028363216, 1.8746727230260916) to (23.38916720601566, 1.67065480042969, 1.8746727230260916)
INFO:root:layer processor `linesort` execution complete (0.005s)
INFO:root:executing layer processor `linesort` on layer 13379 (kwargs: {'two_opt': True, 'no_flip': False})
INFO:root:optimize: reduced pen-up (distance, mean, median) from (29.859837039708523, 2.132845502836323, 1.8746727230260958) to (23.389167206015713, 1.6706548004296937, 1.8746727230260958)
INFO:root:layer processor `linesort` execution complete (0.005s)

12750.22643475841 -> 5361.155188942335 in 6.169s

Squeezed out 11% in 77x the time.

@codecov
Copy link

codecov bot commented May 6, 2021

Codecov Report

Merging #266 (8eabfff) into master (9f7837c) will decrease coverage by 0.30%.
The diff coverage is 78.57%.

❗ Current head 8eabfff differs from pull request most recent head ee1c20d. Consider uploading reports for the commit ee1c20d to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #266      +/-   ##
==========================================
- Coverage   91.72%   91.42%   -0.31%     
==========================================
  Files          50       50              
  Lines        3794     3870      +76     
  Branches      495      509      +14     
==========================================
+ Hits         3480     3538      +58     
- Misses        210      223      +13     
- Partials      104      109       +5     
Impacted Files Coverage Δ
vpype_cli/operations.py 90.66% <77.77%> (-6.05%) ⬇️
tests/test_commands.py 99.59% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f7837c...ee1c20d. Read the comment docs.

@tatarize tatarize changed the title Added linesort two-op operation ( #173) Added linesort two-op operation May 6, 2021
@tatarize tatarize marked this pull request as draft May 7, 2021 05:15
@tatarize tatarize marked this pull request as ready for review May 7, 2021 08:12
@tatarize
Copy link
Contributor Author

tatarize commented May 7, 2021

It's 20% less distance at a cost of 11x the time. Rewrote it in numpy. So a 12k pen distance dropped to a 5.9k then with 10x the time to do that it dropped 20% more to 4.9k. Taking 0.08 seconds initially to 0.93 seconds.

@tatarize
Copy link
Contributor Author

tatarize commented May 7, 2021

@abey79 I'm not sure how to fix the codecov stuff. It yells at me anytime I try to mess with the testing stuff. I assume any test that invokes it would fix that.

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 7, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@tatarize
Copy link
Contributor Author

tatarize commented Jun 3, 2021

@abey79 I failed to jump through the required hoops, but this is pretty solid code. I am in no way attached to this integration, but much significant improvements to linesort might be code worth having.

@abey79
Copy link
Owner

abey79 commented Jun 3, 2021

Yeah, I plan to integrate this in the next release. Hope to be able do that inside of the next couple of weeks.

abey79 added 3 commits June 7, 2021 16:52
- removed `--work` (now relies on global `-vv` option)
- added a couple of tests
- CHANGELOG.md updated
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 8, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

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.

2 participants