DeepDiffs.jl provides the deepdiff
function, which finds and displays differences (diffs) between Julia data structures. It supports Vector
s, Dict
s, and String
s. When diffing dictionaries where values associated with a particular key may change, deepdiff
will recurse into value to provide a more detailed diff.
Many users will likely only use the deepdiff
function to interactively visualize diffs. For more advanced usage, the return value from deepdiff
will be some subtype of the DeepDiff
abstract type which can be further manipulated. These subtypes support the following functions:
before(diff)
: returns the first original (left-hand-side) value that was diffedafter(diff)
: returns the modified (right-hand-side) value that was diffedadded(diff)
: returns a list of indices or dictionary keys that were new items. These indices correspond to the "after" value.removed(diff)
: returns a list of indices or dictionary keys that were removed. These indices correspond to the "before" value.changed(diff)
: returns a dictionary whose keys are indices or dictionary keys and whose values are themselvesDeepDiff
s that describe the modified value. Currently this is only meaningful when diffing dictionaries because the keys can be matched up between the original and modified values.
Vector
s are diffed using a longest-subsequence algorithm that tries to minmize the number of additions and removals necessary to transform one Vector
to another.
Dict
s are diffed by matching up the keys between the original and modified values, so it can recognize removed, added, or modified values.
If color is disabled then the additions and removals are displayed a little differently:
Single-line strings are diffed character-by-character. The indices returned by added
and removed
correspond to indices in the Vector
of characters returned by collect(str::String)
.
Multi-line strings (strings with at least one newline) are diffed line-by-line. The indices returned by added
and removed
correspond to line numbers.