tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

Add examples of using numpy traversal methods

Open benjeffery opened this issue 4 years ago • 2 comments

See https://github.com/tskit-dev/tskit/issues/1788

benjeffery avatar Nov 26 '21 12:11 benjeffery

I discussed this with @jeromekelleher - we wondered whether the example in the tutorial would be better moved to a section of the docs (not the tutorials), designed for simple examples like this. There we could illustrate 4 methods of getting the total branch length of a tree:

  1. Using tree.nodes() to iterate through
  2. Using numpy arrays
  3. High performance, using numpy arrays and numba
  4. Using the built-in branch length method

It would be nice to illustrate the difference in speed between the two, by picking an example that took (e.g.) 1 sec for method (1).

hyanwong avatar Nov 26 '21 14:11 hyanwong

An example of 2. is given in https://github.com/tskit-dev/tskit/issues/1788#issuecomment-983979167

hyanwong avatar Dec 01 '21 20:12 hyanwong