Skip to content

Commit 37199ed

Browse files
committed
Update pre-commit
1 parent 9fc519e commit 37199ed

File tree

9 files changed

+27
-30
lines changed

9 files changed

+27
-30
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v5.0.0
44
hooks:
55
- id: check-merge-conflict
66
- id: debug-statements
77
- id: mixed-line-ending
88
- id: check-case-conflict
99
- id: check-yaml
1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.4.5
11+
rev: v0.11.0
1212
hooks:
1313
- id: ruff
1414
args: [ "--fix", "--config", "ruff.toml" ]

tests/test_accuracy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TestAccuracy:
4141
Test for some of the basic functions used in tsdate
4242
"""
4343

44-
@pytest.mark.makefiles()
44+
@pytest.mark.makefiles
4545
def test_make_static_files(self, request):
4646
"""
4747
The function used to create the tree sequences for accuracy testing.

tests/test_cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,7 @@ def test_probability_space(self, tmp_path):
389389
params = f"-n {self.popsize} --probability-space linear --method inside_outside"
390390
self.verify(tmp_path, input_ts, params)
391391
params = (
392-
f"-n {self.popsize} --probability-space logarithmic "
393-
"--method inside_outside"
392+
f"-n {self.popsize} --probability-space logarithmic --method inside_outside"
394393
)
395394
self.verify(tmp_path, input_ts, params)
396395

tests/test_functions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_one_tree_n2(self):
101101
span_data = self.verify_spans(ts)
102102
# with a single tree there should only be one span
103103
for node in span_data.nodes_to_date:
104-
assert len(span_data.get_spans(node)), 1
104+
assert len(span_data.get_spans(node)) == 1
105105
assert 2 in span_data.get_spans(2)[ts.num_samples]["descendant_tips"]
106106

107107
def test_one_tree_n3(self):
@@ -110,7 +110,7 @@ def test_one_tree_n3(self):
110110
span_data = self.verify_spans(ts)
111111
# with a single tree there should only be one span
112112
for node in span_data.nodes_to_date:
113-
assert len(span_data.get_spans(node)), 1
113+
assert len(span_data.get_spans(node)) == 1
114114
for nd, expd_tips in [
115115
(4, 3), # Node 4 (root) expected to have 3 descendant tips
116116
(3, 2),
@@ -123,7 +123,7 @@ def test_one_tree_n4(self):
123123
span_data = self.verify_spans(ts)
124124
# with a single tree there should only be one span
125125
for node in span_data.nodes_to_date:
126-
assert len(span_data.get_spans(node)), 1
126+
assert len(span_data.get_spans(node)) == 1
127127
for nd, expd_tips in [
128128
(6, 4), # Node 6 (root) expected to have 4 descendant tips
129129
(5, 3), # Node 5 (1st internal node) expected to have 3 descendant tips

tests/test_inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ class TestVariational:
453453
"""
454454

455455
@pytest.fixture(autouse=True)
456-
def ts(self): # noqa PT004
456+
def ts(self):
457457
ts = msprime.sim_ancestry(
458458
samples=10,
459459
recombination_rate=1e-8,

tsdate/cli.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ def tsdate_cli_parser():
7272
parser = subparsers.add_parser(
7373
"date",
7474
help=(
75-
"Takes an inferred tree sequence topology and "
76-
"returns a dated tree sequence."
75+
"Takes an inferred tree sequence topology and returns a dated tree sequence."
7776
),
7877
)
7978

@@ -87,8 +86,7 @@ def tsdate_cli_parser():
8786
parser.add_argument(
8887
"output",
8988
help=(
90-
"The path and name of output file where the dated tree "
91-
"sequence will saved."
89+
"The path and name of output file where the dated tree sequence will saved."
9290
),
9391
)
9492
parser.add_argument(

tsdate/discrete.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ def get_mut_lik_fixed_node(self, edge):
207207
that are equal to or older than the child age. This is not cached, as it is
208208
likely to be unique for each edge
209209
"""
210-
assert (
211-
edge.child in self.fixednodes
212-
), "Wrongly called fixed node function on non-fixed node"
213-
assert (
214-
self.mut_rate is not None
215-
), "Cannot calculate mutation likelihoods with no mutation_rate set"
210+
assert edge.child in self.fixednodes, (
211+
"Wrongly called fixed node function on non-fixed node"
212+
)
213+
assert self.mut_rate is not None, (
214+
"Cannot calculate mutation likelihoods with no mutation_rate set"
215+
)
216216

217217
mutations_on_edge = self.mut_edges[edge.id]
218218
child_time = self.ts.node(edge.child).time
@@ -235,12 +235,12 @@ def get_mut_lik_lower_tri(self, edge):
235235
236236
"""
237237
# Debugging asserts - should probably remove eventually
238-
assert (
239-
edge.child not in self.fixednodes
240-
), "Wrongly called lower_tri function on fixed node"
241-
assert hasattr(
242-
self, "unfixed_likelihood_cache"
243-
), "Must call `precalculate_mutation_likelihoods()` before getting likelihoods"
238+
assert edge.child not in self.fixednodes, (
239+
"Wrongly called lower_tri function on fixed node"
240+
)
241+
assert hasattr(self, "unfixed_likelihood_cache"), (
242+
"Must call `precalculate_mutation_likelihoods()` before getting likelihoods"
243+
)
244244

245245
mutations_on_edge = self.mut_edges[edge.id]
246246
return self.unfixed_likelihood_cache[mutations_on_edge, edge.span]
@@ -598,9 +598,9 @@ def inside_pass(self, *, standardize=True, cache_inside=False, progress=None):
598598
(self.ts.num_edges, self.lik.grid_size), self.lik.identity_constant
599599
)
600600
denominator = np.full(self.ts.num_nodes, np.nan)
601-
assert (
602-
self.lik.standardize is False
603-
), "Marginal likelihood requires unstandardized mutation likelihoods"
601+
assert self.lik.standardize is False, (
602+
"Marginal likelihood requires unstandardized mutation likelihoods"
603+
)
604604
marginal_lik = self.lik.identity_constant
605605
# Iterate through the nodes via groupby on parent node
606606
for parent, edges in tqdm(

tsdate/evaluation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ def allele_frequency_spectra(
726726
ax.text(
727727
0.02,
728728
0.98,
729-
f"{i+1}:{j+1}",
729+
f"{i + 1}:{j + 1}",
730730
ha="left",
731731
va="top",
732732
transform=ax.transAxes,

tsdate/hypergeo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"""
2626

2727
import ctypes
28-
from math import erf, exp, lgamma, log, pi, pow, sqrt
28+
from math import erf, exp, lgamma, log, pi, pow, sqrt # noqa: A004
2929

3030
import numba
3131
import numpy as np

0 commit comments

Comments
 (0)