jeetsukumaran / DendroPy

A Python library for phylogenetic scripting, simulation, data processing and manipulation.
https://pypi.org/project/DendroPy/.
BSD 3-Clause "New" or "Revised" License
207 stars 62 forks source link

Remove deprecated `random.sample` from `Tree.shuffle_taxa()` #155

Closed mmore500 closed 1 year ago

mmore500 commented 1 year ago

Replaces random sampling of a set with random swap-and-pop on a list. Closes #154.

jeetsukumaran commented 1 year ago

Hi @mmore500 -- thanks for this.

One reason we originally use sets here is to take advantage of the O(1) lookup rather than the O(n) for lists. Now, I cannot remember how important this time savings is here or if I've profiled the code, but I'm glad to see that this potential efficiencyis preserved by the dictionary look-up. Nice work!