deepdiff
deepdiff copied to clipboard
How to get result if max_diffs used
Hi,
Is there a way to achive, to know that there is difference but to exit on max_diffs=1 ?
For example:
a1 = {"a": 1, "b": [3,2,1]}
a2 = {"b": [1,2,3], "a": 1}
result = DeepDiff(
a1,
a2,
ignore_order=True,
report_repetition=True,
ignore_string_case=True,
exclude_regex_paths=[r"(?i)\['link'\]$"],
ignore_string_type_changes=True,
max_diffs=1
)
and
a1 = {"a": 1, "b": [3,2,1]}
a2 = {"b": [1,2,3], "a": 9999}
result = DeepDiff(
a1,
a2,
ignore_order=True,
report_repetition=True,
ignore_string_case=True,
exclude_regex_paths=[r"(?i)\['link'\]$"],
ignore_string_type_changes=True,
max_diffs=1
)
will return same result
{}
with
{'PASSES COUNT': 0, 'DIFF COUNT': 2, 'DISTANCE CACHE HIT COUNT': 0, 'MAX PASS LIMIT REACHED': False, 'MAX DIFF LIMIT REACHED': True}
But they are not same, if we do not use max_diffs only second example is different.
Is there a way to achive this ?
Thanks in advance.
Hi @drsasa Sorry for the very late response. max_diffs in DeepDiff is basically telling it to quit diffing once certain number of comparisons are made. Not necessarily certain number of differences are detected. This question usually comes up because the diff calculation can be heavy. Your best bet to tune DeepDiff to get you some answer quickly is explained here: https://zepworks.com/deepdiff/current/optimizations.html I would start with https://zepworks.com/deepdiff/current/ignore_order.html#cutoff-intersection-for-pairs-label and https://zepworks.com/deepdiff/current/ignore_order.html#cutoff-distance-for-pairs for getting a less granular result when ignore_order=True