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.
use numpy.linalg.norm instead of scipy.spatial.distance (see this SO comment and this SO answer for performance benchmarks)
cache all Circle instances when we create an instance of Rings, and compute all separations via numpy
I've benchmarked the above 2 on the bullseye and rings shapes, and the results are nice:
# bullseye on main
218292773 function calls (215844061 primitive calls) in 85.438 seconds
# bullseye w/ this PR
211510859 function calls (209069591 primitive calls) in 82.753 seconds
# rings on main
224466386 function calls (222017681 primitive calls) in 86.428 seconds
# rings w/ this PR
210318700 function calls (207877434 primitive calls) in 82.098 seconds
While the relative performance improvement appears marginal, it only appears that way due to Pandas-related operations being the bottleneck, and for bullseye we get 6.7M less function calls, while for rings we get 14.1M less function calls in total.
Note that no changes were made to the public API.
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).
Fixes #202
Describe your changes
numpy.linalg.norm
instead ofscipy.spatial.distance
(see this SO comment and this SO answer for performance benchmarks)Circle
instances when we create an instance ofRings
, and compute all separations via numpyI've benchmarked the above 2 on the
bullseye
andrings
shapes, and the results are nice:While the relative performance improvement appears marginal, it only appears that way due to Pandas-related operations being the bottleneck, and for
bullseye
we get 6.7M less function calls, while forrings
we get 14.1M less function calls in total.Note that no changes were made to the public API.
Checklist