Skip to content

Make TreeSequence.samples args kw only #1831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
- Metadata encoding errors now raise ``MetadataEncodingError``
(:user:`benjeffery`, :issue:`1505`, :pr:`1827`).

- For ``TreeSequence.samples`` all arguments after ``population`` are now keyword only
(:user:`benjeffery`, :issue:`1715`, :pr:`1831`).

**Features**

- Add ``TableCollection.sort_individuals`` to sort the individuals as this is no longer done by the
Expand Down
5 changes: 5 additions & 0 deletions python/tests/test_highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,11 @@ def test_samples_time_errors(self):
with pytest.raises(ValueError):
ts.samples(time=(2.4, 1))

def test_samples_args(self, ts_fixture):
ts_fixture.samples(1)
with pytest.raises(TypeError, match="takes from 1 to 2 positional arguments"):
ts_fixture.samples(1, 2)

def test_genotype_matrix_indexing(self):
num_demes = 4
ts = self.get_tree_sequence(num_demes)
Expand Down
2 changes: 1 addition & 1 deletion python/tskit/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -4851,7 +4851,7 @@ def get_samples(self, population_id=None):
# Deprecated alias for samples()
return self.samples(population_id)

def samples(self, population=None, population_id=None, time=None):
def samples(self, population=None, *, population_id=None, time=None):
"""
Returns an array of the sample node IDs in this tree sequence. If
`population` is specified, only return sample IDs from that population.
Expand Down