diff --git a/scripts/diff_jsons.py b/scripts/diff_jsons.py index ece69de4d..ce215e855 100644 --- a/scripts/diff_jsons.py +++ b/scripts/diff_jsons.py @@ -15,6 +15,7 @@ parser.add_argument("--significant-digits", type=int, default=5, help="number of significant digits to use when comparing numeric values") parser.add_argument("--exclude-paths", nargs="+", help="list of paths to exclude from consideration when performing a diff", default=["root['generated_by']['version']"]) parser.add_argument("--exclude-regex-paths", nargs="+", help="list of path regular expressions to exclude from consideration when performing a diff") + parser.add_argument("--ignore-numeric-type-changes", action="store_true", help="ignore numeric type changes in the diff (e.g., int of 1 to float of 1.0)") args = parser.parse_args() @@ -31,5 +32,6 @@ significant_digits=args.significant_digits, exclude_paths=args.exclude_paths, exclude_regex_paths=args.exclude_regex_paths, + ignore_numeric_type_changes=args.ignore_numeric_type_changes, ) ) diff --git a/tests/functional/export_v2/cram/minimal.t b/tests/functional/export_v2/cram/minimal.t index a423a393a..9fd1c1eda 100644 --- a/tests/functional/export_v2/cram/minimal.t +++ b/tests/functional/export_v2/cram/minimal.t @@ -16,12 +16,10 @@ Minimal export -- single input (tree) and single output (dataset JSON) The above minimal.json takes divergence from the newick file. This converts newick divergences of (e.g.) '1' to `1.0` -because BioPython uses floats (which is perfectly reasonable). Remove the decimal to diff the JSON. +because BioPython uses floats (which is perfectly reasonable). Ignore this type change in the JSON diff. (Note that Auspice won't behave any differently) - $ sed 's/\.0//' minimal.json > minimal.no-decimal.json - - $ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/minimal.json" minimal.no-decimal.json \ + $ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" --ignore-numeric-type-changes "$TESTDIR/../data/minimal.json" minimal.json \ > --exclude-paths "root['meta']['updated']" {}