Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additional difference algorithm suggeestion #44

Closed
mgcdanny opened this issue Dec 5, 2014 · 4 comments
Closed

additional difference algorithm suggeestion #44

mgcdanny opened this issue Dec 5, 2014 · 4 comments

Comments

@mgcdanny
Copy link

mgcdanny commented Dec 5, 2014

Hi,

This dictdiffer library rocks! Thank you all.

This might be another nice difference algorithm per #42. Basically similar to the symmetric difference operator from python's Set data structure.

Setup:

a = {'numbers' : [1, 2, 3]}
b = {'numbers': [0, 1, 2, 3]}

result = dd.diff(a, b)
for r in result:
    print(r)

Current output:

('change', ['numbers', 0], (1, 0))
('change', ['numbers', 1], (2, 1))
('change', ['numbers', 2], (3, 2))
('add', 'numbers', [(3, 3)])

Proposed output:

('symmetric_diff', ['numbers'], (, 0))

So (,0) would represent the addition of 0 to the second dict and that everything in the first dict is contained in the second. I think this would be like

(set(a) - set(b), set(b)-set(a))

Or at least some way of getting at the fact that the value 0 was added to the second list and not the value 3.

Cheers!

jirikuncar added a commit to jirikuncar/dictdiffer that referenced this issue Dec 7, 2014
* Adds support for diffing and patching of sets.  (addresses inveniosoftware#44)

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
@jirikuncar
Copy link
Member

@mgcdanny what do you think about support for sets in #45?

a = {'numbers' : {1, 2, 3}}
b = {'numbers': {0, 1, 2, 3}}
assert list(diff(a, b)) == [('add', ['numbers'], (0, {0}))]

@jirikuncar jirikuncar added this to the v0.4.0 milestone Dec 7, 2014
@mgcdanny
Copy link
Author

mgcdanny commented Dec 7, 2014

Yeah, that seems to works really nicely. Good idea! Thanks

@lnielsen
Copy link
Member

lnielsen commented Dec 8, 2014

+1

jirikuncar added a commit to jirikuncar/dictdiffer that referenced this issue Dec 8, 2014
* Adds support for diffing and patching of sets.  (addresses inveniosoftware#44)

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
jirikuncar added a commit to jirikuncar/dictdiffer that referenced this issue Dec 8, 2014
* Adds support for diffing and patching of sets.  (addresses inveniosoftware#44)

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
jirikuncar added a commit to jirikuncar/dictdiffer that referenced this issue Dec 9, 2014
* Adds support for diffing and patching of sets.  (addresses inveniosoftware#44)

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
@tiborsimko
Copy link
Member

Closing the issue now that PR #45 was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants