Skip to content

Commit 691a294

Browse files
benjefferymergify[bot]
authored andcommitted
Update pre-commit
1 parent c8568d5 commit 691a294

11 files changed

+73
-68
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v3.2.0
3+
rev: v4.1.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/benjeffery/pre-commit-clang-format
11-
rev: '1.0'
11+
rev: c21a74d089aaeb86c2c19df371c7e7bf40c07207
1212
hooks:
1313
- id: clang-format
1414
exclude: avl
1515
verbose: true
1616
- repo: https://github.com/asottile/reorder_python_imports
17-
rev: v2.3.5
17+
rev: v3.0.1
1818
hooks:
1919
- id: reorder-python-imports
2020
args: [ --unclassifiable-application-module=_tsinfer ]
2121
- repo: https://github.com/asottile/pyupgrade
22-
rev: v2.7.2
22+
rev: v2.31.1
2323
hooks:
2424
- id: pyupgrade
25-
args: [ --py3-plus, --py36-plus ]
25+
args: [ --py3-plus, --py37-plus ]
2626
- repo: https://github.com/psf/black
27-
rev: 20.8b1
27+
rev: 22.3.0
2828
hooks:
2929
- id: black
3030
language_version: python3
3131
- repo: https://github.com/asottile/blacken-docs
32-
rev: v1.8.0
32+
rev: v1.12.1
3333
hooks:
3434
- id: blacken-docs
3535
args: [--skip-errors]
36-
additional_dependencies: [black==20.8b1]
36+
additional_dependencies: [black==22.3.0]
3737
language_version: python3
3838
- repo: https://gitlab.com/pycqa/flake8
39-
rev: 3.8.3
39+
rev: 3.9.2
4040
hooks:
4141
- id: flake8
4242
args: [--config=.flake8]
43-
additional_dependencies: ["flake8-bugbear==20.1.4", "flake8-builtins==1.5.2"]
43+
additional_dependencies: ["flake8-bugbear==22.3.23", "flake8-builtins==1.5.3"]

dev.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ def tsinfer_dev(
6767

6868
np.random.seed(seed)
6969
random.seed(seed)
70-
L_megabases = int(L * 10 ** 6)
70+
L_megabases = int(L * 10**6)
7171

7272
# daiquiri.setup(level=log_level)
7373

7474
source_ts = msprime.simulate(
7575
n,
76-
Ne=10 ** 4,
76+
Ne=10**4,
7777
length=L_megabases,
7878
recombination_rate=recombination_rate,
7979
mutation_rate=1e-8,
@@ -211,7 +211,7 @@ def dump_provenance(ts):
211211

212212

213213
def build_profile_inputs(n, num_megabases):
214-
L = num_megabases * 10 ** 6
214+
L = num_megabases * 10**6
215215
input_file = "tmp__NOBACKUP__/profile-n={}-m={}.input.trees".format(
216216
n, num_megabases
217217
)
@@ -221,7 +221,7 @@ def build_profile_inputs(n, num_megabases):
221221
ts = msprime.simulate(
222222
n,
223223
length=L,
224-
Ne=10 ** 4,
224+
Ne=10**4,
225225
recombination_rate=1e-8,
226226
mutation_rate=1e-8,
227227
random_seed=10,
@@ -281,10 +281,10 @@ def tutorial_samples():
281281

282282
ts = msprime.simulate(
283283
sample_size=10000,
284-
Ne=10 ** 4,
284+
Ne=10**4,
285285
recombination_rate=1e-8,
286286
mutation_rate=1e-8,
287-
length=10 * 10 ** 6,
287+
length=10 * 10**6,
288288
random_seed=42,
289289
)
290290
ts.dump("tmp__NOBACKUP__/simulation-source.trees")

docs/simulation-example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
if True:
1111
ts = msprime.simulate(
1212
sample_size=10000,
13-
Ne=10 ** 4,
13+
Ne=10**4,
1414
recombination_rate=1e-8,
1515
mutation_rate=1e-8,
16-
length=10 * 10 ** 6,
16+
length=10 * 10**6,
1717
random_seed=42,
1818
)
1919
ts.dump("simulation-source.trees")

docs/tutorial.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ data under the coalescent with recombination, using `msprime
130130
131131
ts = msprime.simulate(
132132
sample_size=10000,
133-
Ne=10 ** 4,
133+
Ne=10**4,
134134
recombination_rate=1e-8,
135135
mutation_rate=1e-8,
136-
length=10 * 10 ** 6,
136+
length=10 * 10**6,
137137
random_seed=42,
138138
)
139139
ts.dump("simulation-source.trees")

evaluation.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def edges_performance_worker(args):
237237

238238
def run_edges_performance(args):
239239
num_lengths = 10
240-
MB = 10 ** 6
240+
MB = 10**6
241241

242242
work = []
243243
rng = random.Random()
@@ -251,7 +251,7 @@ def run_edges_performance(args):
251251
"mutation_rate": args.mutation_rate,
252252
"Ne": args.Ne,
253253
"model": "smc_prime",
254-
"random_seed": rng.randint(1, 2 ** 30),
254+
"random_seed": rng.randint(1, 2**30),
255255
}
256256
work.append((sim_args, args.compute_tree_metrics, args.engine))
257257

@@ -423,7 +423,7 @@ def unrank(samples, n):
423423

424424
def edge_plot(ts, filename):
425425
n = ts.num_samples
426-
pallete = sns.color_palette("husl", 2 ** n - 1)
426+
pallete = sns.color_palette("husl", 2**n - 1)
427427
lines = []
428428
colours = []
429429
for tree in ts.trees():
@@ -445,7 +445,7 @@ def edge_plot(ts, filename):
445445

446446

447447
def run_hotspot_analysis(args):
448-
MB = 10 ** 6
448+
MB = 10**6
449449
L = args.length * MB
450450

451451
rng = random.Random()
@@ -467,7 +467,7 @@ def run_hotspot_analysis(args):
467467
"recombination_map": recomb_map,
468468
"mutation_rate": args.mutation_rate,
469469
"Ne": args.Ne,
470-
"random_seed": rng.randint(1, 2 ** 30),
470+
"random_seed": rng.randint(1, 2**30),
471471
}
472472
ts = msprime.simulate(**sim_args)
473473
print("simulated ", ts.num_trees, "trees and", ts.num_sites, "sites")
@@ -562,7 +562,7 @@ def ancestor_properties_worker(args):
562562

563563
def run_ancestor_properties(args):
564564
num_lengths = 10
565-
MB = 10 ** 6
565+
MB = 10**6
566566

567567
work = []
568568
rng = random.Random()
@@ -577,7 +577,7 @@ def run_ancestor_properties(args):
577577
"mutation_rate": args.mutation_rate,
578578
"Ne": args.Ne,
579579
"model": "smc_prime",
580-
"random_seed": rng.randint(1, 2 ** 30),
580+
"random_seed": rng.randint(1, 2**30),
581581
}
582582
work.append((sim_args, not args.skip_exact))
583583

@@ -702,7 +702,7 @@ def imputation_accuracy_worker(args):
702702

703703

704704
def run_imputation_accuracy(args):
705-
MB = 10 ** 6
705+
MB = 10**6
706706

707707
work = []
708708
rng = random.Random()
@@ -716,7 +716,7 @@ def run_imputation_accuracy(args):
716716
"recombination_rate": args.recombination_rate,
717717
"mutation_rate": args.mutation_rate,
718718
"Ne": args.Ne,
719-
"random_seed": rng.randint(1, 2 ** 30),
719+
"random_seed": rng.randint(1, 2**30),
720720
}
721721
work.append((sim_args, missing_proportion))
722722
# imputation_accuracy_worker((sim_args, missing_proportion))
@@ -802,7 +802,7 @@ def sim_true_and_inferred_ancestors(args):
802802
Run a simulation under args and return the samples, plus the true and the inferred
803803
ancestors
804804
"""
805-
MB = 10 ** 6
805+
MB = 10**6
806806
rng = random.Random(args.random_seed)
807807
np.random.seed(args.random_seed)
808808
sim_args = {
@@ -812,7 +812,7 @@ def sim_true_and_inferred_ancestors(args):
812812
"mutation_rate": args.mutation_rate,
813813
"Ne": args.Ne,
814814
"model": "smc_prime",
815-
"random_seed": rng.randint(1, 2 ** 30),
815+
"random_seed": rng.randint(1, 2**30),
816816
}
817817
ts = msprime.simulate(**sim_args)
818818

@@ -1342,7 +1342,7 @@ def run_ancestor_quality(args):
13421342
print(" " * (olap_start_exact - offset1), end="")
13431343
print(" " * (olap_start_estim - offset2), end="")
13441344
elif args.print_bad_ancestors == "inferred":
1345-
print("{:<5}".format(int(freq[focal_pos])), end="")
1345+
print(f"{int(freq[focal_pos]):<5}", end="")
13461346
k = 0
13471347
mask = estim_sites_mask[olap_start_estim:olap_end_estim]
13481348
for j, (bit, curr_pos) in enumerate(
@@ -1526,7 +1526,7 @@ def run_ancestor_quality(args):
15261526
color="k",
15271527
markeredgewidth=0.5,
15281528
markerfacecolor="w",
1529-
markersize=1 ** 0.5,
1529+
markersize=1**0.5,
15301530
),
15311531
mp.lines.Line2D(
15321532
[],
@@ -1537,7 +1537,7 @@ def run_ancestor_quality(args):
15371537
color="k",
15381538
markeredgewidth=0.5,
15391539
markerfacecolor="w",
1540-
markersize=10 ** 0.5,
1540+
markersize=10**0.5,
15411541
),
15421542
mp.lines.Line2D(
15431543
[],
@@ -1548,7 +1548,7 @@ def run_ancestor_quality(args):
15481548
color="k",
15491549
markeredgewidth=0.5,
15501550
markerfacecolor="w",
1551-
markersize=100 ** 0.5,
1551+
markersize=100**0.5,
15521552
),
15531553
]
15541554
name = "quality-by-freq-with-bias"
@@ -1704,7 +1704,7 @@ def get_node_degree_by_depth(ts):
17041704

17051705

17061706
def run_node_degree(args):
1707-
MB = 10 ** 6
1707+
MB = 10**6
17081708
rng = random.Random()
17091709
if args.random_seed is not None:
17101710
rng.seed(args.random_seed)
@@ -1715,7 +1715,7 @@ def run_node_degree(args):
17151715
"mutation_rate": args.mutation_rate,
17161716
"Ne": args.Ne,
17171717
"model": "smc_prime",
1718-
"random_seed": rng.randint(1, 2 ** 30),
1718+
"random_seed": rng.randint(1, 2**30),
17191719
}
17201720
smc_ts = msprime.simulate(**sim_args)
17211721

@@ -1804,11 +1804,11 @@ def run_perfect_inference(args):
18041804
rng = random.Random()
18051805
rng.seed(args.random_seed)
18061806
for _ in range(args.num_replicates):
1807-
seed = rng.randint(1, 2 ** 30)
1807+
seed = rng.randint(1, 2**30)
18081808
base_ts = msprime.simulate(
18091809
args.sample_size,
18101810
Ne=args.Ne,
1811-
length=args.length * 10 ** 6,
1811+
length=args.length * 10**6,
18121812
recombination_rate=1e-8,
18131813
random_seed=seed,
18141814
model=model,
@@ -1867,7 +1867,7 @@ def add_standard_arguments(
18671867
):
18681868
parser.add_argument("--destination-dir", "-d", default="")
18691869
parser.add_argument("--sample-size", "-n", type=int, default=sample_size)
1870-
parser.add_argument("--Ne", "-N", type=int, default=10 ** 4)
1870+
parser.add_argument("--Ne", "-N", type=int, default=10**4)
18711871
parser.add_argument(
18721872
"--length", "-l", type=float, default=length, help="Sequence length in MB"
18731873
)

tests/test_formats.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def test_too_small_max_file_size_init(self):
238238

239239
def test_too_small_max_file_size_add(self):
240240
with tempfile.TemporaryDirectory(prefix="tsinf_format_test") as tempdir:
241-
base_size = 2 ** 16 # Big enough to allow the initial file to be created
241+
base_size = 2**16 # Big enough to allow the initial file to be created
242242
# Fail during adding a large amount of data
243243
with pytest.raises(lmdb.MapFullError):
244244
filename = os.path.join(tempdir, "samples.tmp")
@@ -257,8 +257,8 @@ def test_acceptable_max_file_size(self):
257257
with tempfile.TemporaryDirectory(prefix="tsinf_format_test") as tempdir:
258258
# set a reasonably large number of sites and samples, and check we
259259
# don't bomb out
260-
n_samples = 2 ** 10
261-
n_sites = 2 ** 12
260+
n_samples = 2**10
261+
n_sites = 2**12
262262
np.random.seed(123)
263263
filename = os.path.join(tempdir, "samples.tmp")
264264
with formats.SampleData(
@@ -331,7 +331,7 @@ def test_from_tree_sequence_bad_times(self):
331331
tables = ts.dump_tables()
332332
# Associate nodes at different times with a single individual
333333
nodes_time = tables.nodes.time
334-
min_time = min([n.time for n in ts.nodes() if not n.is_sample()])
334+
min_time = min(n.time for n in ts.nodes() if not n.is_sample())
335335
nodes_time[ts.samples()] = np.linspace(0, min_time, n_individuals * ploidy)
336336
tables.nodes.time = nodes_time
337337
# Zap out the mutation times to avoid conflicts.
@@ -2324,7 +2324,9 @@ def test_ancestors_truncated_length(self):
23242324
assert np.array_equal(
23252325
trunc_lengths[time < upper_limit], original_lengths[time < upper_limit]
23262326
)
2327-
for orig_anc, trunc_anc in zip(ancestors.ancestors(), trunc_anc.ancestors()):
2327+
for orig_anc, trunc_anc in zip( # noqa: B020
2328+
ancestors.ancestors(), trunc_anc.ancestors()
2329+
):
23282330
assert orig_anc.time == trunc_anc.time
23292331
assert np.array_equal(orig_anc.focal_sites, trunc_anc.focal_sites)
23302332
if orig_anc.time >= upper_limit:
@@ -2348,7 +2350,9 @@ def test_truncate_extreme_interval(self):
23482350
ancestors = tsinfer.generate_ancestors(sample_data)
23492351
time = ancestors.ancestors_time[:]
23502352
trunc_anc = ancestors.truncate_ancestors(np.min(time), np.max(time), 1)
2351-
for orig_anc, trunc_anc in zip(ancestors.ancestors(), trunc_anc.ancestors()):
2353+
for orig_anc, trunc_anc in zip( # noqa: B020
2354+
ancestors.ancestors(), trunc_anc.ancestors()
2355+
):
23522356
assert orig_anc.start == trunc_anc.start
23532357
assert orig_anc.end == trunc_anc.end
23542358
assert orig_anc.time == trunc_anc.time
@@ -2359,7 +2363,9 @@ def test_truncate_extreme_interval(self):
23592363
ancestors = tsinfer.generate_ancestors(sample_data)
23602364
time = ancestors.ancestors_time[:]
23612365
trunc_anc = ancestors.truncate_ancestors(0, 1, 1)
2362-
for orig_anc, trunc_anc in zip(ancestors.ancestors(), trunc_anc.ancestors()):
2366+
for orig_anc, trunc_anc in zip( # noqa: B020
2367+
ancestors.ancestors(), trunc_anc.ancestors()
2368+
):
23632369
assert orig_anc.start == trunc_anc.start
23642370
assert orig_anc.end == trunc_anc.end
23652371
assert orig_anc.time == trunc_anc.time
@@ -2374,7 +2380,9 @@ def test_one_haplotype_truncated(self):
23742380
oldest_site = np.max(sites_time)
23752381
midpoint = np.median(sites_time)
23762382
trunc_anc = ancestors.truncate_ancestors(midpoint, oldest_site, 1)
2377-
for orig_anc, trunc_anc in zip(ancestors.ancestors(), trunc_anc.ancestors()):
2383+
for orig_anc, trunc_anc in zip( # noqa: B020
2384+
ancestors.ancestors(), trunc_anc.ancestors()
2385+
):
23782386
assert orig_anc.time == trunc_anc.time
23792387
assert np.array_equal(orig_anc.focal_sites, trunc_anc.focal_sites)
23802388

0 commit comments

Comments
 (0)