GeezerVison is showing github.com — comparing lists of sets if ignore_order=True #19 · fellow/deepdiff@8d1267e
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: AUTHORS +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,3 +6,4 @@ Thanks to: | 6 | 6 | * nfvs for Travis-CI setup script | 7 | 7 | * brbsix for initial Py3 porting | 8 | 8 | * WangFenjin for unicode support | | 9 | + * timoilya for comparing list of sets when ignoring order |
Collapse file Copy file name to clipboardExpand all lines: README.md +2-1Lines changed: 2 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -# deepdiff v 1.0.0 | | 1 | +# deepdiff v 1.0.1 | 2 | 2 |
| 3 | 3 |  | 4 | 4 |  | @@ -233,6 +233,7 @@ int, string, dictionary, list, tuple, set, frozenset, OrderedDict, NamedTuple an | 233 | 233 |
| 234 | 234 | ##Changelog | 235 | 235 |
| | 236 | +- v1-0-1: Better ignore order support | 236 | 237 | - v1-0-0: Restructuring output to make it more useful. This is NOT backward compatible. | 237 | 238 | - v0-6-1: Fixiing iterables with unhashable when order is ignored | 238 | 239 | - v0-6-0: Adding unicode support | |
Collapse file Copy file name to clipboardExpand all lines: README.txt +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -**DeepDiff v 1.0.0** | | 1 | +**DeepDiff v 1.0.1** | 2 | 2 |
| 3 | 3 | Deep Difference of dictionaries, iterables, strings and almost any other object. It will recursively look for all the changes. | 4 | 4 |
| @@ -179,6 +179,7 @@ Object attribute added: | 179 | 179 |
| 180 | 180 | **Changelog** | 181 | 181 |
| | 182 | +- v1-0-1: Better ignore order support | 182 | 183 | - v1-0-0: Restructuring output to make it more useful. This is NOT backward compatible. | 183 | 184 | - v0-6-1: Fixiing iterables with unhashable when order is ignored | 184 | 185 | - v0-6-0: Adding unicode support | |
Collapse file Copy file name to clipboardExpand all lines: deepdiff/deepdiff.py +6-10Lines changed: 6 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 |
| 6 | 6 | import difflib | 7 | 7 | import datetime | 8 | | -import json | | 8 | +try: | | 9 | + import cPickle as pickle | | 10 | +except: | | 11 | + import pickle | 9 | 12 | from decimal import Decimal | 10 | 13 | from sys import version | 11 | 14 | from collections import Iterable | @@ -49,7 +52,7 @@ class ListItemRemovedOrAdded(object): | 49 | 52 | class DeepDiff(dict): | 50 | 53 |
| 51 | 54 | r""" | 52 | | - **DeepDiff v 1.0.0** | | 55 | + **DeepDiff v 1.0.1** | 53 | 56 |
| 54 | 57 | Deep Difference of dictionaries, iterables, strings and almost any other object. | 55 | 58 | It will recursively look for all the changes. | @@ -388,7 +391,7 @@ def __create_hashtable(t, parent): | 388 | 391 | item_hash = hash(item) | 389 | 392 | except TypeError: | 390 | 393 | try: | 391 | | - item_hash = hash(json.dumps(item, default=json_default)) | | 394 | + item_hash = hash(pickle.dumps(item)) | 392 | 395 | except Exception as e: | 393 | 396 | print ("Warning: Can not produce a hash for %s item in %s and\ | 394 | 397 | thus not counting this object. %s" % (item, parent, e)) | @@ -474,13 +477,6 @@ def changes(self): | 474 | 477 | return self | 475 | 478 |
| 476 | 479 |
| 477 | | -def json_default(obj): | 478 | | - '''Dealing with unserializable objects''' | 479 | | - if isinstance(obj, Decimal): | 480 | | - return float(obj) | 481 | | - else: | 482 | | - raise TypeError | 483 | | - | 484 | 480 | if __name__ == "__main__": | 485 | 481 | import doctest | 486 | 482 | doctest.testmod() |
Collapse file Copy file name to clipboardExpand all lines: docs/conf.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 59 | 59 | # built documents. | 60 | 60 | # | 61 | 61 | # The short X.Y version. | 62 | | -version = '1.0.0' | | 62 | +version = '1.0.1' | 63 | 63 | # The full version, including alpha/beta/rc tags. | 64 | | -release = '1.0.0' | | 64 | +release = '1.0.1' | 65 | 65 |
| 66 | 66 | # The language for content autogenerated by Sphinx. Refer to documentation | 67 | 67 | # for a list of supported languages. | |
Collapse file Copy file name to clipboardExpand all lines: docs/index.rst +2-1Lines changed: 2 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -20,7 +20,7 @@ Install from PyPi:: | 20 | 20 |
| 21 | 21 |
| 22 | 22 | ************** | 23 | | -DeepDiff 1.0.0 | | 23 | +DeepDiff 1.0.1 | 24 | 24 | ************** | 25 | 25 |
| 26 | 26 | .. toctree:: | @@ -44,6 +44,7 @@ Indices and tables | 44 | 44 | Changelog | 45 | 45 | ========= | 46 | 46 |
| | 47 | +- v1-0-1: Better ignore order support | 47 | 48 | - v1-0-0: Restructuring output to make it more useful. This is NOT backward compatible. | 48 | 49 | - v0-6-1: Fixiing iterables with unhashable when order is ignored | 49 | 50 | - v0-6-0: Adding unicode support | |
Collapse file Copy file name to clipboardExpand all lines: setup.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | long_description = "Deep Difference of dictionaries, iterables, strings and other objects. It will recursively look for all the changes." | 14 | 14 |
| 15 | 15 | setup(name='deepdiff', | 16 | | - version='1.0.0', | | 16 | + version='1.0.1', | 17 | 17 | description='Deep Difference of dictionaries, iterables, strings and other objects. It will recursively look for all the changes.', | 18 | 18 | url='https://github.com/seperman/deepdiff', | 19 | 19 | download_url='https://github.com/seperman/deepdiff/tarball/master', | |
Collapse file Copy file name to clipboardExpand all lines: tests/tests.py +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 4 | 4 | """ | 5 | 5 | To run the test, run this in the root of repo: | 6 | 6 | python -m unittest discover | | 7 | +
| | 8 | +To run a specific test, run this from the root of repo: | | 9 | +python -m unittest tests.DeepDiffTestCase.test_list_of_sets_difference_ignore_order | 7 | 10 | """ | 8 | 11 | import unittest | 9 | 12 | from decimal import Decimal | @@ -123,6 +126,13 @@ def test_list_of_unhashable_difference_ignore_order2(self): | 123 | 126 | 'iterable_item_removed': {'root[3]': 'B', 'root[0]': 1}} | 124 | 127 | self.assertEqual(ddiff, result) | 125 | 128 |
| | 129 | + def test_list_of_sets_difference_ignore_order(self): | | 130 | + t1 = [{1}, {2}, {3}] | | 131 | + t2 = [{4}, {1}, {2}, {3}] | | 132 | + ddiff = DeepDiff(t1, t2, ignore_order=True) | | 133 | + result = {'iterable_item_added': {'root[0]': {4}}} | | 134 | + self.assertEqual(ddiff, result) | | 135 | + | 126 | 136 | def test_list_that_contains_dictionary(self): | 127 | 137 | t1 = {1: 1, 2: 2, 3: 3, 4: {"a": "hello", "b": [1, 2, {1: 1, 2: 2}]}} | 128 | 138 | t2 = {1: 1, 2: 2, 3: 3, 4: {"a": "hello", "b": [1, 2, {1: 3}]}} | |
|