Skip to content

Commit 0f8ab16

Browse files
committed
Update pre-commit
1 parent 9db058c commit 0f8ab16

File tree

10 files changed

+62
-90
lines changed

10 files changed

+62
-90
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
3+
rev: v5.0.0
44
hooks:
55
- id: check-merge-conflict
66
- id: debug-statements
@@ -14,22 +14,22 @@ repos:
1414
exclude: argtable3
1515
verbose: true
1616
- repo: https://github.com/asottile/reorder_python_imports
17-
rev: v3.12.0
17+
rev: v3.14.0
1818
hooks:
1919
- id: reorder-python-imports
2020
args: [--unclassifiable-application-module=_msprime]
2121
- repo: https://github.com/asottile/pyupgrade
22-
rev: v3.15.0
22+
rev: v3.19.1
2323
hooks:
2424
- id: pyupgrade
2525
args: [--py38-plus]
2626
- repo: https://github.com/psf/black
27-
rev: 23.9.1
27+
rev: 25.1.0
2828
hooks:
2929
- id: black
3030
language_version: python3
3131
- repo: https://github.com/pycqa/flake8
32-
rev: 6.1.0
32+
rev: 7.1.2
3333
hooks:
3434
- id: flake8
3535
args: [--config=.flake8]

algorithms.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Python version of the simulation algorithm.
3-
"""
1+
# Python version of the simulation algorithm.
42
from __future__ import annotations
53

64
import argparse

data/run_old_msprime.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
"""
2-
Runs the parameters for a given simulation in an input
3-
pickle file and writes the output tree sequence to
4-
an output file.
5-
"""
1+
# Runs the parameters for a given simulation in an input
2+
# pickle file and writes the output tree sequence to
3+
# an output file.
64
import pickle
75
import sys
86

msp_dev.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Simple shim for msp development.
3-
"""
1+
# Simple shim for msp development.
42
import msprime.cli
53

64
if __name__ == "__main__":

mspms_dev.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Simple shim for mspms development.
3-
"""
1+
# Simple shim for mspms development.
42
import msprime.cli
53

64
if __name__ == "__main__":

stress_lowlevel.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
"""
2-
Code to stress the low-level API as much as possible to expose
3-
any memory leaks or error handling issues.
4-
"""
1+
# Code to stress the low-level API as much as possible to expose
2+
# any memory leaks or error handling issues.
53
import curses
64
import os
75
import random

tests/test_algorithms.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Tests for the algorithms.py script.
3-
"""
1+
# Tests for the algorithms.py script.
42
import pathlib
53
import platform
64
import tempfile

tests/test_dict_encoding.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
"""
2-
Test cases for the low-level dictionary encoding used to move
3-
data around in C.
4-
"""
1+
# Test cases for the low-level dictionary encoding used to move
2+
# data around in C.
53
import lwt_interface.dict_encoding_testlib
64

75
from msprime import _msprime

tests/test_mutations.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,9 +2141,11 @@ def populate_tables(self, tables):
21412141
parent=parent_id,
21422142
metadata=mutation.metadata,
21432143
# Not sure why, but sometimes the time is a single-element array
2144-
time=mutation.time[0]
2145-
if isinstance(mutation.time, np.ndarray)
2146-
else mutation.time,
2144+
time=(
2145+
mutation.time[0]
2146+
if isinstance(mutation.time, np.ndarray)
2147+
else mutation.time
2148+
),
21472149
)
21482150
assert mutation_id > parent_id
21492151
mutation.id = mutation_id

verification.py

Lines changed: 41 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,40 @@
1-
"""
2-
Script to automate verification of msprime against known statistical
3-
results and benchmark programs such as ms and Seq-Gen.
4-
5-
Tests are structured in a similar way to Python unittests. Tests
6-
are organised into classes of similar tests. Ideally, each test
7-
in the class is a simple call to a general method with
8-
different parameters (this is called ``_run``, by convention).
9-
Tests must be *independent* and not depend on any shared
10-
state within the test class, other than the ``self.output_dir``
11-
variable which is guaranteed to be set when the method is called.
12-
13-
The output directory is <output-dir>/<class name>/<test name>.
14-
Each test should output one or more diagnostic plots, which have
15-
a clear interpretation as "correct" or "incorrect". QQ-plots
16-
are preferred, where possible. Numerical results can also be
17-
output by using ``logging.debug()``, where appropriate; to
18-
view these, append ``--debug`` to the comand line running
19-
your tests.
20-
21-
Test classes must be a subclass of the ``Test`` class defined
22-
in this module.
23-
24-
To run the tests, first get some help from the CLI:
25-
26-
python3 verification.py --help
27-
28-
This will output some basic help on the tests. Use
29-
30-
python3 verification.py --list
31-
32-
to show all the available tests.
33-
34-
If you run without any arguments, this will run all the tests
35-
sequentially. The progress bar and output behaviour can be
36-
controlled using command line parameters, and running over
37-
multiple processes is possible.
38-
39-
If you wish to run a specific tests, you can provide the
40-
test names as positional arguments, i.e.,
41-
42-
python3 verification.py test_msdoc_outgroup_sequence test_msdoc_recomb_ex
43-
44-
will just run these two specific tests.
45-
46-
Using the ``-c`` option allows you to run all tests in a
47-
given class.
48-
49-
Gotchas:
50-
- Any test superclasses must be abstract. That is, you cannot
51-
inherit from a test class that contains any tests.
52-
- Test method names must be unique across *all* classes.
53-
54-
"""
1+
# Script to automate verification of msprime against known statistical
2+
# results and benchmark programs such as ms and Seq-Gen.
3+
# Tests are structured in a similar way to Python unittests. Tests
4+
# are organised into classes of similar tests. Ideally, each test
5+
# in the class is a simple call to a general method with
6+
# different parameters (this is called ``_run``, by convention).
7+
# Tests must be *independent* and not depend on any shared
8+
# state within the test class, other than the ``self.output_dir``
9+
# variable which is guaranteed to be set when the method is called.
10+
# The output directory is <output-dir>/<class name>/<test name>.
11+
# Each test should output one or more diagnostic plots, which have
12+
# a clear interpretation as "correct" or "incorrect". QQ-plots
13+
# are preferred, where possible. Numerical results can also be
14+
# output by using ``logging.debug()``, where appropriate; to
15+
# view these, append ``--debug`` to the comand line running
16+
# your tests.
17+
# Test classes must be a subclass of the ``Test`` class defined
18+
# in this module.
19+
# To run the tests, first get some help from the CLI:
20+
# python3 verification.py --help
21+
# This will output some basic help on the tests. Use
22+
# python3 verification.py --list
23+
# to show all the available tests.
24+
# If you run without any arguments, this will run all the tests
25+
# sequentially. The progress bar and output behaviour can be
26+
# controlled using command line parameters, and running over
27+
# multiple processes is possible.
28+
# If you wish to run a specific tests, you can provide the
29+
# test names as positional arguments, i.e.,
30+
# python3 verification.py test_msdoc_outgroup_sequence test_msdoc_recomb_ex
31+
# will just run these two specific tests.
32+
# Using the ``-c`` option allows you to run all tests in a
33+
# given class.
34+
# Gotchas:
35+
# - Any test superclasses must be abstract. That is, you cannot
36+
# inherit from a test class that contains any tests.
37+
# - Test method names must be unique across *all* classes.
5538
import argparse
5639
import ast
5740
import collections
@@ -5643,9 +5626,10 @@ def _run_seq_gen(self, tree, args, model, alleles, num_sites, mutation_rate, Q):
56435626
newick = tree.newick()
56445627
cmd = self._seq_gen_executable + args
56455628
num_sequences = 2 * ts.num_samples - 1
5646-
with tempfile.TemporaryFile("w+") as in_file, tempfile.TemporaryFile(
5647-
"w+"
5648-
) as out_file:
5629+
with (
5630+
tempfile.TemporaryFile("w+") as in_file,
5631+
tempfile.TemporaryFile("w+") as out_file,
5632+
):
56495633
in_file.write(newick)
56505634
in_file.seek(0)
56515635
subprocess.call(cmd, stdin=in_file, stdout=out_file)

0 commit comments

Comments
 (0)