stefmolin / data-morph

Morph an input dataset of 2D points into select shapes, while preserving the summary statistics to a given number of decimal points through simulated annealing. It is intended to be used as a teaching tool to illustrate the importance of data visualization.
https://stefaniemolin.com/data-morph/
MIT License
60 stars 16 forks source link

Replace many Pandas operations with NumPy #198

Open JCGoran opened 2 months ago

JCGoran commented 2 months ago

Describe your changes

Perf before:

320361688 function calls (316213771 primitive calls) in 116.715 seconds

Perf after:

79419311 function calls (78769517 primitive calls) in 43.085 seconds

which is more or less in-line with the circular shapes.

Checklist

stefmolin commented 2 months ago

Thanks for the PR, @JCGoran! As I'm sure you've seen, I have a backlog to get through :smile: I hope to get to this in the next few weeks.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.42%. Comparing base (51b8d26) to head (e708f6c). Report is 11 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/stefmolin/data-morph/pull/198/graphs/tree.svg?width=650&height=150&src=pr&token=3SEEG9SZQO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Stefanie+Molin)](https://app.codecov.io/gh/stefmolin/data-morph/pull/198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Stefanie+Molin) ```diff @@ Coverage Diff @@ ## main #198 +/- ## ======================================= Coverage 98.42% 98.42% ======================================= Files 43 43 Lines 1775 1778 +3 Branches 358 356 -2 ======================================= + Hits 1747 1750 +3 Misses 25 25 Partials 3 3 ``` | [Files](https://app.codecov.io/gh/stefmolin/data-morph/pull/198?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Stefanie+Molin) | Coverage Δ | | |---|---|---| | [src/data\_morph/data/dataset.py](https://app.codecov.io/gh/stefmolin/data-morph/pull/198?src=pr&el=tree&filepath=src%2Fdata_morph%2Fdata%2Fdataset.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Stefanie+Molin#diff-c3JjL2RhdGFfbW9ycGgvZGF0YS9kYXRhc2V0LnB5) | `73.75% <100.00%> (+0.67%)` | :arrow_up: | | [src/data\_morph/data/stats.py](https://app.codecov.io/gh/stefmolin/data-morph/pull/198?src=pr&el=tree&filepath=src%2Fdata_morph%2Fdata%2Fstats.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Stefanie+Molin#diff-c3JjL2RhdGFfbW9ycGgvZGF0YS9zdGF0cy5weQ==) | `100.00% <100.00%> (ø)` | | | [src/data\_morph/morpher.py](https://app.codecov.io/gh/stefmolin/data-morph/pull/198?src=pr&el=tree&filepath=src%2Fdata_morph%2Fmorpher.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Stefanie+Molin#diff-c3JjL2RhdGFfbW9ycGgvbW9ycGhlci5weQ==) | `100.00% <100.00%> (ø)` | | | [src/data\_morph/plotting/static.py](https://app.codecov.io/gh/stefmolin/data-morph/pull/198?src=pr&el=tree&filepath=src%2Fdata_morph%2Fplotting%2Fstatic.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Stefanie+Molin#diff-c3JjL2RhdGFfbW9ycGgvcGxvdHRpbmcvc3RhdGljLnB5) | `100.00% <100.00%> (ø)` | | | [tests/data/test\_stats.py](https://app.codecov.io/gh/stefmolin/data-morph/pull/198?src=pr&el=tree&filepath=tests%2Fdata%2Ftest_stats.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Stefanie+Molin#diff-dGVzdHMvZGF0YS90ZXN0X3N0YXRzLnB5) | `100.00% <100.00%> (ø)` | | | [tests/test\_morpher.py](https://app.codecov.io/gh/stefmolin/data-morph/pull/198?src=pr&el=tree&filepath=tests%2Ftest_morpher.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Stefanie+Molin#diff-dGVzdHMvdGVzdF9tb3JwaGVyLnB5) | `100.00% <100.00%> (ø)` | |