Skip to content

Commit

Permalink
Pin deepdiff to later version
Browse files Browse the repository at this point in the history
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
  • Loading branch information
huddlej committed Sep 4, 2024
1 parent fbb4f3b commit c2274e3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
test = [
"coverage[toml] >=5.2.1, ==5.*",
"cram >=0.7, ==0.*",
"deepdiff[cli] >=5.2.0, ==5.*",
"deepdiff[cli] >=8.0.0, ==8.*",
"flake8 >=3.9.0, ==3.*",
"pylint >=2.14.5, ==2.*",
]
Expand Down
39 changes: 39 additions & 0 deletions scripts/diff_tsv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Compare TSV files line by line with deepdiff
"""
import argparse
import deepdiff
import pandas as pd


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Compare TSV files line by line with deepdiff",
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument("first_tsv", help="first TSV to compare")
parser.add_argument("second_tsv", help="second TSV to compare")
parser.add_argument("--significant-digits", type=int, default=6, help="number of significant digits to use when comparing numeric values")

args = parser.parse_args()

first_tsv = pd.read_csv(
args.first_tsv,
sep="\t",
header=None,
na_filter=False,
).to_dict()

second_tsv = pd.read_csv(
args.second_tsv,
sep="\t",
header=None,
na_filter=False,
).to_dict()

print(
deepdiff.DeepDiff(
first_tsv,
second_tsv,
significant_digits=args.significant_digits,
)
)
2 changes: 1 addition & 1 deletion tests/functional/forecast.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Forecast frequencies with a model trained on simulated data.
> --model data/simulated_sample_1/normalized_fitness.json \
> --delta-months 12 \
> --output-table "$TMP/forecasts.tsv" > /dev/null
$ deep diff --significant-digits 6 "data/simulated_sample_1/forecasts.tsv" "$TMP/forecasts.tsv"
$ python3 ../../scripts/diff_tsv.py "data/simulated_sample_1/forecasts.tsv" "$TMP/forecasts.tsv"
{}
$ rm -f "$TMP/forecasts.tsv"

Expand Down

0 comments on commit c2274e3

Please sign in to comment.