Skip to content

Commit c2274e3

Browse files
committed
Pin deepdiff to later version
Pins deepdiff to the latest version (8) which includes a fix a PyYAML dependency issue with Cython [1]. Also, replaces the deep diff CLI command in a functional test with a custom Python script that uses the DeepDiff class, working around an issue where the deep diff CLI did not properly recognize numeric values and caused the functional test to fail spuriously. This commit should fix CI for Python versions 3.10 and 3.11. [1] seperman/deepdiff#406
1 parent fbb4f3b commit c2274e3

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies = [
3030
test = [
3131
"coverage[toml] >=5.2.1, ==5.*",
3232
"cram >=0.7, ==0.*",
33-
"deepdiff[cli] >=5.2.0, ==5.*",
33+
"deepdiff[cli] >=8.0.0, ==8.*",
3434
"flake8 >=3.9.0, ==3.*",
3535
"pylint >=2.14.5, ==2.*",
3636
]

scripts/diff_tsv.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""Compare TSV files line by line with deepdiff
2+
"""
3+
import argparse
4+
import deepdiff
5+
import pandas as pd
6+
7+
8+
if __name__ == "__main__":
9+
parser = argparse.ArgumentParser(
10+
description="Compare TSV files line by line with deepdiff",
11+
formatter_class=argparse.ArgumentDefaultsHelpFormatter
12+
)
13+
parser.add_argument("first_tsv", help="first TSV to compare")
14+
parser.add_argument("second_tsv", help="second TSV to compare")
15+
parser.add_argument("--significant-digits", type=int, default=6, help="number of significant digits to use when comparing numeric values")
16+
17+
args = parser.parse_args()
18+
19+
first_tsv = pd.read_csv(
20+
args.first_tsv,
21+
sep="\t",
22+
header=None,
23+
na_filter=False,
24+
).to_dict()
25+
26+
second_tsv = pd.read_csv(
27+
args.second_tsv,
28+
sep="\t",
29+
header=None,
30+
na_filter=False,
31+
).to_dict()
32+
33+
print(
34+
deepdiff.DeepDiff(
35+
first_tsv,
36+
second_tsv,
37+
significant_digits=args.significant_digits,
38+
)
39+
)

tests/functional/forecast.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Forecast frequencies with a model trained on simulated data.
99
> --model data/simulated_sample_1/normalized_fitness.json \
1010
> --delta-months 12 \
1111
> --output-table "$TMP/forecasts.tsv" > /dev/null
12-
$ deep diff --significant-digits 6 "data/simulated_sample_1/forecasts.tsv" "$TMP/forecasts.tsv"
12+
$ python3 ../../scripts/diff_tsv.py "data/simulated_sample_1/forecasts.tsv" "$TMP/forecasts.tsv"
1313
{}
1414
$ rm -f "$TMP/forecasts.tsv"
1515

0 commit comments

Comments
 (0)