Skip to content

Commit

Permalink
Update to pyinat main HEAD and simplify taxon tree handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
synrg committed Aug 22, 2024
1 parent c8a1fb3 commit d5879a7
Show file tree
Hide file tree
Showing 3 changed files with 274 additions and 267 deletions.
12 changes: 2 additions & 10 deletions dronefly/core/formatters/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,13 @@ def taxa_per_rank(
_sort_rank_obs_name(order) if sort_by == "obs" else _sort_rank_name(order)
)

if not any(taxon.rank in include_ranks for taxon in taxon_list):
return []
tree = make_tree(
taxon_list,
include_ranks=include_ranks,
root_id=root_taxon_id,
sort_key=sort_key,
# max_depth=max_depth,
)
hide_root = (
tree.id == ROOT_TAXON_ID
or include_ranks
and len(include_ranks) == 1
and tree.rank != include_ranks[0]
)
root_taxon = None
if max_depth == 1:
if root_taxon_id:
Expand All @@ -222,7 +214,7 @@ def taxa_per_rank(
)
else:
root_taxon = taxon_list[0]
for taxon in tree.flatten(hide_root=hide_root):
for taxon in tree.flatten():
included = True
# TODO: determine if the taxon is a leaf some other way if the object
# doesn't have both both a direct & descendant count
Expand Down Expand Up @@ -266,7 +258,7 @@ def included_ranks(per_rank: str):
for rank in COMMON_RANKS:
ranks += RANKS_FOR_LEVEL[RANK_LEVELS[rank]]
else:
ranks = list(RANK_LEVELS.keys())
ranks = [key for key in RANK_LEVELS.keys() if key != "stateofmatter"]
return ranks


Expand Down
Loading

0 comments on commit d5879a7

Please sign in to comment.