Skip to content

Conversation

@benjeffery
Copy link
Member

@benjeffery benjeffery commented Nov 14, 2025

Stacked on #3319

@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 74.57627% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.86%. Comparing base (5ffcf6f) to head (4558bdb).

Files with missing lines Patch % Lines
python/tskit/trees.py 0.00% 11 Missing ⚠️
python/_tskitmodule.c 91.66% 2 Missing and 2 partials ⚠️

❗ There is a different number of reports uploaded between BASE (5ffcf6f) and HEAD (4558bdb). Click for more details.

HEAD has 22 uploads less than BASE
Flag BASE (5ffcf6f) HEAD (4558bdb)
python-tests-no-jit 12 6
python-tests-numpy1 2 1
c-tests 2 1
lwt-tests 2 1
python-c-tests 2 1
python-tests 12 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3326       +/-   ##
===========================================
- Coverage   89.72%   77.86%   -11.86%     
===========================================
  Files          29       29               
  Lines       31181    31220       +39     
  Branches     5720     5726        +6     
===========================================
- Hits        27976    24311     -3665     
- Misses       1796     5385     +3589     
- Partials     1409     1524      +115     
Flag Coverage Δ
c-tests 86.76% <ø> (+0.05%) ⬆️
lwt-tests 80.38% <ø> (ø)
python-c-tests 87.09% <91.66%> (+0.03%) ⬆️
python-tests ?
python-tests-no-jit 33.59% <0.00%> (+0.03%) ⬆️
python-tests-numpy1 50.16% <0.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
python/_tskitmodule.c 87.09% <91.66%> (+0.03%) ⬆️
python/tskit/trees.py 68.32% <0.00%> (-30.57%) ⬇️

... and 14 files with indirect coverage changes

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

@jeromekelleher
Copy link
Member

Slightly uneasy about the API breakage here, although I agree it's the right approach. I guess returning a numpy array is in practise quite similar to returning an iterator?

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.

Generally looks good!

bool(isolated_as_missing),
)

flat_arr = np.frombuffer(
Copy link
Member

Choose a reason for hiding this comment

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

Can you test that this is definitely the same underlying buffer as the low-level version? A copy would be bad here.

num_nodes = (tsk_size_t) PyArray_DIM(nodes_array, 0);
nodes = PyArray_DATA(nodes_array);

Py_ssize_t total
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit convoluted cast-wise, what about

total = (Py_ssize_t)(num_nodes  * (tsk_size_t)(right - left)

standard crib about declarations at the top.

}
buf = PyBytes_AS_STRING(buf_obj);

Py_BEGIN_ALLOW_THREADS err = tsk_treeseq_decode_alignments(self->tree_sequence,
Copy link
Member

Choose a reason for hiding this comment

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

You have to turn off clang format locally to prevent it messing things up around Py_BEGIN_ALLOW_THREADS

@benjeffery
Copy link
Member Author

I guess returning a numpy array is in practise quite similar to returning an iterator?

I'm 50/50 on it - I don't like that the iterator suggests to the user that this is a memory efficient method, but you're right that it is bit of a break, although for i in alignments should still work.

@benjeffery
Copy link
Member Author

But then haplotypes returns an iterator - so probably best to follow that pattern or change haplotypes too.

@jeromekelleher
Copy link
Member

I think we follow the pattern. We can add another more explicit numpy approach later if needed. Not breaking stuff is what we do.

@jeromekelleher
Copy link
Member

Also iterator pattern would allow us do things like specify a memory budget,which would be quite handy

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.

2 participants