I previously added an experimental LifeList.tree() method to render a life list (example on iNat) as a tree on the terminal.
This would be useful in some new features in Dronefly, so it would be worth cleaning this up a bit by separating the logic from display format.
Options
Options include:
rich.Tree subclass with .taxon attribute (with some additions I mentioned in PR comments)
pyinat.Taxon tree
Root node would be a Taxon object, with children recursively added using the existing .children attribute
Add a separate function to convert it to a rich.Tree for console display (which would work for any arbitrary taxon with children)
Hybrid class that inherits from both Taxon and Tree
Currently leaning toward option 2.
Other features
It would also be useful to allow making a tree from any collection of Taxon objects as long as there is exactly one root taxon.
Should this be determined by either id == 48460, or parent_id isn't in the list of taxa?
Related
Note: this is suitable for the size of, say, a typical user's life list (hundreds to maybe tens of thousands of taxa for power users), but it probably wouldn't perform well enough for datasets significantly larger than that.
I previously added an experimental
LifeList.tree()
method to render a life list (example on iNat) as a tree on the terminal.This would be useful in some new features in Dronefly, so it would be worth cleaning this up a bit by separating the logic from display format.
Options
Options include:
rich.Tree
subclass with.taxon
attribute (with some additions I mentioned in PR comments)pyinat.Taxon
treeTaxon
object, with children recursively added using the existing.children
attributerich.Tree
for console display (which would work for any arbitrary taxon with children)Taxon
andTree
Currently leaning toward option 2.
Other features
It would also be useful to allow making a tree from any collection of Taxon objects as long as there is exactly one root taxon. Should this be determined by either
id == 48460
, orparent_id
isn't in the list of taxa?Related
Note: this is suitable for the size of, say, a typical user's life list (hundreds to maybe tens of thousands of taxa for power users), but it probably wouldn't perform well enough for datasets significantly larger than that.
For navigating the entire iNat taxonomy tree (~1.2 million taxa), there is this module, which uses pandas and multiprocessing: https://pyinaturalist-convert.readthedocs.io/en/stable/modules/taxonomy.html Any similar features that need better performance could be done there.