Skip to content

Comments

Fix: nodes at t#85

Closed
BadPrograms wants to merge 3 commits intocode-split-3from
fix--nodes_at_t
Closed

Fix: nodes at t#85
BadPrograms wants to merge 3 commits intocode-split-3from
fix--nodes_at_t

Conversation

@BadPrograms
Copy link
Collaborator

If some of the roots existed in t while others started later, the ones that existed would not be added to the result.

Copy link
Member

@leoguignard leoguignard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different proposition on how to solve the bug, and some small suggestions on how to improve the code

Comment on lines 369 to 378
t = lT.t_e
to_do = list(r)
to_do = []
final_nodes = []
for root in r:
if lT.time[root] == t:
final_nodes.append(root)
else:
to_do.append(root)
while len(to_do) > 0:
curr = to_do.pop()
for _next in lT._successor[curr]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion, keeping as is, only changing the while:

while 0 < len(to_do):
    curr = to_do.pop()
    if lT._time[curr] == t:
        final_nodes.append(curr)
    elif lT._time[curr] < t:
        to_do.extend(lT.successor[curr])

I think it also allows the removal of

if not final_nodes:
    return list(r)

@@ -366,8 +366,13 @@ def nodes_at_t(
r = [r]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I guess one could do it that way at the beginning:

if r is None:
    ...

Instead of

if not r and r != 0:
    ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yes, it would change the behavior since it would make the function return nothing in case the user gave [] for roots instead of returning the output of lT.roots which is I think a plus.
If the user specifically gave the empty list of nodes, it should not get any node in the return value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have time_nodes again, I don't care about the behaviour, so I will do that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually since we have the time_nodes the function should change entirely.

Copy link
Collaborator Author

@BadPrograms BadPrograms Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think we might want to return a set and not a list. There is no reason to index the result, and I like sets more. The only reason to use a list is that the rest of the LineageTree consists mostly of lists, so we can do so for the sake of consistency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I guess one could do it that way at the beginning:

if r is None:
...

Instead of

if not r and r != 0:
...

Dont you want to do that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should the function change? and what should it be instead?

About the list vs set, the list can have an advantadge since it is explicitly ordered and that currently the nodes are returned in a specific order (preorder)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we dont provide roots it should return lT.time_nodes[t]

@@ -366,8 +366,13 @@ def nodes_at_t(
r = [r]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I guess one could do it that way at the beginning:

if r is None:
...

Instead of

if not r and r != 0:
...

Dont you want to do that?

@@ -366,8 +366,13 @@ def nodes_at_t(
r = [r]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should the function change? and what should it be instead?

About the list vs set, the list can have an advantadge since it is explicitly ordered and that currently the nodes are returned in a specific order (preorder)

@codecov
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.91%. Comparing base (93ee2ca) to head (994a0f9).
⚠️ Report is 12 commits behind head on code-split-3.

Additional details and impacted files
@@              Coverage Diff              @@
##           code-split-3      #85   +/-   ##
=============================================
  Coverage         96.91%   96.91%           
=============================================
  Files                 2        2           
  Lines               356      356           
  Branches             17       17           
=============================================
  Hits                345      345           
  Misses                6        6           
  Partials              5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leoguignard
Copy link
Member

added to code-split-4

Closing for that reason

@jules-vanaret jules-vanaret deleted the fix--nodes_at_t branch September 8, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants