Msprime: Make API more Pythonic by removing lots of 'get_'s

Created on 23 Oct 2016  路  5Comments  路  Source: tskit-dev/msprime

Several aspects of the API are a little non-Pythonic. Mainly, this involves using methods like obj.get_x() rather than obj.x.

For example, we should change:

  • SparseTree.get_root() -> SparseTree.root
  • SparseTree.get_index() -> SparseTree.index
  • SparseTree.get_interval() -> SparseTree.interval
  • TreeSequence.get_sample_size() -> TreeSequence.sample_size
  • TreeSequence.get_num_mutations() -> TreeSequence.num_mutations

Also, we should change things like

  • SparseTree.get_branch_length(u) -> SparseTree.branch_length(u)
  • SparseTree.get_mrca(u, v) -> SparseTree.mrca(u, v)

Existing methods should all be marked as deprecated, removed from the documentation, and (eventually) removed entirely.

enhancement help wanted

All 5 comments

I could help out as I familiarize myself with the API. I opened a PR with a list of candidate functions

A question: should the above be eg SparseTree.root()? (you don't intend to change them from instance methods, right?)

This is great @ashander, thanks! I think we do want to make them properties; I'll go into more detail on how your PR.

sometimes I think github should have a 'like' buttom for things like this

Finally finished this up in #384.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

molpopgen picture molpopgen  路  4Comments

jeromekelleher picture jeromekelleher  路  7Comments

petrelharp picture petrelharp  路  10Comments

nspope picture nspope  路  12Comments

jeromekelleher picture jeromekelleher  路  7Comments