Skip to content

Commit

Permalink
added nodes time refactor code for issue no. #2766
Browse files Browse the repository at this point in the history
  • Loading branch information
PalashLalwani authored and mergify[bot] committed Jun 21, 2023
1 parent b579afc commit 93cd81f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ build-gcc
python/benchmark/*.trees
python/benchmark/*.json
python/benchmark/*.html
.venv
.env

4 changes: 2 additions & 2 deletions python/tskit/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -4561,14 +4561,14 @@ def max_root_time(self):
raise ValueError(
"max_root_time is not defined in a tree sequence with 0 samples"
)
ret = max(self.node(u).time for u in self.samples())
ret = max(self.nodes_time[u] for u in self.samples())

This comment has been minimized.

Copy link
@hyanwong

hyanwong Jul 5, 2023

Member

Could probably do this without the loop, right?

self.nodes_time[self.samples()].max()
if self.num_edges > 0:
# Edges are guaranteed to be listed in parent-time order, so we can get the
# last one to get the oldest root
edge = self.edge(self.num_edges - 1)
# However, we can have situations where there is a sample older than a
# 'proper' root
ret = max(ret, self.node(edge.parent).time)
ret = max(ret, self.nodes_time[edge.parent])
return ret

def migrations(self):
Expand Down

0 comments on commit 93cd81f

Please sign in to comment.