Skip to content

Conversation

@hyanwong
Copy link
Member

Fixes #783

@hyanwong
Copy link
Member Author

Exciting segfault here. Will investigate!

@hyanwong hyanwong force-pushed the edge_diff_include_terminal branch 4 times, most recently from 9fc9623 to 45d3530 Compare August 21, 2020 19:24
@hyanwong
Copy link
Member Author

So I've been fiddling with this for a good while, and it doesn't segfault on my machine, so I can't work out why it does on circleCI, especially as it fails on an old test, and I have defaulted to unchanged behaviour. Any help spotting my mistake here would be vrey gratefully accepted @benjeffery or @jeromekelleher. It would be helpful to have this PR working so that I can sort out the KC polytomy-breaking stuff for Wilder.

@benjeffery
Copy link
Member

I can look at this - hopefully will be able to recreate!

@hyanwong
Copy link
Member Author

Thanks so much. I wouldn't normally pester, but I've been banging my head against it for a few hours now!

@benjeffery
Copy link
Member

My previous traumatic experiences with the Python C API have helped here. A close reading of https://docs.python.org/3/c-api/arg.html#other-objects shows that an int is needed to receive a bool from python. I've committed a fix to your branch.

@benjeffery benjeffery added this to the Python 0.3.1 milestone Aug 22, 2020
@hyanwong
Copy link
Member Author

Thanks. I'd never have caught that!

Copy link
Member

@jeromekelleher jeromekelleher left a comment

Choose a reason for hiding this comment

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

Looks good, but needs more tests. Definitely on the C side we want to exercise this on a few different topology types - what happens on an empty ts? An ordinary ts with several trees? We have to think through all the corner cases.

@hyanwong hyanwong force-pushed the edge_diff_include_terminal branch 2 times, most recently from b4a3f1d to 2e7d0fa Compare August 25, 2020 15:25
@hyanwong
Copy link
Member Author

hyanwong commented Aug 25, 2020

Looks good, but needs more tests. Definitely on the C side we want to exercise this on a few different topology types - what happens on an empty ts? An ordinary ts with several trees? We have to think through all the corner cases.

Can we not test an empty ts, multi-tree ts etc at the python level? We have a function get_example_tree_sequences() in test_highlevel.py which can return various pathological tree sequences like this. Actually, having looked at it, I see it doesn't test a ts with no edges, so I'll open a PR for that. (edit - now in #792 )

@jeromekelleher
Copy link
Member

Can we not test an empty ts, multi-tree ts etc at the python level? We have a function get_example_tree_sequences() in test_highlevel.py which can return various pathological tree sequences like this.

No, because we can't run valgrind when Python is running and would therefore not detect memory access issues (which are non-deterministic and differ across platforms, so you can't just say "it doesn't segfault, so it's fine").

There's loads of tests checking for empty tree sequences across the suite - the test_highlevel.py approach isn't how we're doing things any more.

@hyanwong
Copy link
Member Author

No, because we can't run valgrind when Python is running and would therefore not detect memory access issues (which are non-deterministic and differ across platforms, so you can't just say "it doesn't segfault, so it's fine").

Ah, OK. Apart from your suggestion above for all parent[j] == -1, I'm not familiar with the way you might check memory issues here. But now that I have implemented that, perhaps I can just add test_multiroot_diff_iter and test_empty_diff_iter functions to test_trees.c?

There's loads of tests checking for empty tree sequences across the suite - the test_highlevel.py approach isn't how we're doing things any more.

Added anyway: I think there's no harm, and a function to produce a whole set of different semi-pathological tree sequences seems a useful thing to have around.

@jeromekelleher
Copy link
Member

Ah, OK. Apart from your suggestion above for all parent[j] == -1, I'm not familiar with the way you might check memory issues here. But now that I have implemented that, perhaps I can just add test_multiroot_diff_iter and test_empty_diff_iter functions to test_trees.c?

Once the tests are implemented valgrind is run on them automatically, checking for these errors.

Copy link
Member

@benjeffery benjeffery left a comment

Choose a reason for hiding this comment

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

Think I found am incorrect variable usage in the python C layer, and one comment about test style.

@benjeffery benjeffery force-pushed the edge_diff_include_terminal branch from bbe5d41 to cc6464c Compare August 26, 2020 15:12
Copy link
Member

@benjeffery benjeffery left a comment

Choose a reason for hiding this comment

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

Looking good, thanks @hyanwong! We just need a changelog before merge.

@hyanwong hyanwong force-pushed the edge_diff_include_terminal branch from cc6464c to 01c1255 Compare August 28, 2020 08:02
@hyanwong
Copy link
Member Author

Looking good, thanks @hyanwong! We just need a changelog before merge.

Done, thanks. Note that this includes the change in #788 as the first commit in the PR, so that can be PR can be closed if this is merged.

@jeromekelleher
Copy link
Member

Let's hold off on this until our bugfix releases have been shipped.

@hyanwong hyanwong force-pushed the edge_diff_include_terminal branch from 01c1255 to ef51dd4 Compare September 11, 2020 09:46
@hyanwong
Copy link
Member Author

I think this is ready to merge @benjeffery ?

Copy link
Member

@benjeffery benjeffery left a comment

Choose a reason for hiding this comment

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

LGTM, lets merge.

@benjeffery benjeffery force-pushed the edge_diff_include_terminal branch from 2f6a848 to e91b436 Compare September 11, 2020 12:31
@benjeffery
Copy link
Member

@hyanwong I've just force pushed to resolve the conflict and add the change to the C changelog too as this is a change to both APIs.

@mergify mergify bot merged commit 740ec41 into tskit-dev:master Sep 11, 2020
@hyanwong hyanwong deleted the edge_diff_include_terminal branch September 11, 2020 13:07
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.

Extra param in edge_diffs to output all the final edges

3 participants