zhang-shasha icon indicating copy to clipboard operation
zhang-shasha copied to clipboard

Different diffs produce same `Operation` lists

Open SamWilsn opened this issue 2 years ago • 0 comments

I'm attempting to use zss to create a reasonable "patch" between two trees. The following two tree-pairs produce the same set of operations, and I'm not sure how you're supposed to differentiate between them:

graph TD;
    A-->C;
    A-->B;
from zss import Node, simple_distance

before = Node("A")
after = Node("A").addkid(Node("C")).addkid(Node("B"))

_, ops = simple_distance(before, after, return_operations=True)
graph TD;
    A-->B;
    B-->C;
from zss import Node, simple_distance

before = Node("A")
after = Node("A").addkid(Node("B").addkid(Node("C")))

_, ops = simple_distance(before, after, return_operations=True)

Which both result in:

<Operation Insert: None to Node('C')>
<Operation Insert: None to Node('B')>
<Operation Match: Node('A') to Node('A')>

Is this ambiguity intentional (since this is primarily an edit distance library), or am I missing something?

SamWilsn avatar Jun 19 '23 18:06 SamWilsn