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

5.0.0: Delta, Better Numpy support, Pretty view #188

Merged
merged 171 commits into from Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
ecac906
Adds support for datetime.time objects per issue#181
nathanielobrown Mar 25, 2020
f618c9d
Merge pull request #182 from nathanielobrown/master
seperman Mar 26, 2020
85015b1
wip write first test for pretty_form
Apr 11, 2020
cd982dc
updating docs
seperman Apr 12, 2020
e1b2a82
delta wip
seperman Apr 13, 2020
24b8018
delta in progress
seperman Apr 13, 2020
b913c09
serialization wip
seperman Apr 15, 2020
1abada7
adding pickle tests
seperman Apr 16, 2020
feee29a
adding test fixtures for serialization
seperman Apr 16, 2020
0c15d4b
Added basic support for diffing numpy arrays
chkothe Apr 17, 2020
ff1399e
working on delta
seperman Apr 17, 2020
d5f6591
wip add pretty form for values changed, type changed with tests
Apr 17, 2020
245f869
Merge pull request #186 from chkothe/pr/numpy-support-basic
seperman Apr 17, 2020
bf73274
wip on delta
seperman Apr 18, 2020
b523e60
adding sets
seperman Apr 18, 2020
cbed7e3
Merge branch 'dev' of github.com:seperman/deepdiff into dev
seperman Apr 18, 2020
ffcc5d0
delta wip
seperman Apr 18, 2020
761808c
delta wip for type changes
seperman Apr 18, 2020
ce40b1e
dealing with root changes
seperman Apr 19, 2020
9f2540e
wip pretty form
Apr 19, 2020
515851e
fixing tests and post process of delta
seperman Apr 19, 2020
79f94d4
renaming index to elem
seperman Apr 19, 2020
cae65db
delta what
seperman Apr 19, 2020
2b5fafb
wip add all single prints with tests
Apr 20, 2020
dfd4dd1
add quotation marks to string values
Apr 20, 2020
c808d13
delta wip
seperman Apr 20, 2020
0cbeff1
refactor pretty_print_diff
Apr 20, 2020
1c2b17e
delta dict added
seperman Apr 20, 2020
63ddcea
delta dict remove
seperman Apr 20, 2020
7dbdf7d
add root to paths
Apr 20, 2020
67867c0
custom objects delta wip
seperman Apr 20, 2020
dc7f6a9
refactor tests
Apr 20, 2020
42f88b6
custom objects
seperman Apr 20, 2020
e1d076e
fix fullstops in pretty texts
Apr 20, 2020
d711b4e
going down the ignore order
seperman Apr 20, 2020
5e6ace4
Merge branch 'dev' into pretty-view
MKaras93 Apr 21, 2020
22294d3
fix intendation
Apr 21, 2020
12c8714
fixing ignore order for deltas and tuple
seperman Apr 22, 2020
fee5331
deep ignore order wip
seperman Apr 23, 2020
e95c6dd
major progress yay
seperman Apr 23, 2020
3a821e2
adding deep ignoree order to the repetition report too
seperman Apr 23, 2020
432cfca
remove f-strings for python 3.5 compatibility
Apr 23, 2020
85d4018
delta view wip
seperman Apr 23, 2020
8fe8c1c
Merge pull request #187 from MKaras93/pretty-view
seperman Apr 24, 2020
17c38d5
small refactor in deephash
seperman Apr 24, 2020
7084827
fixing deephash hashes dictionary
seperman Apr 24, 2020
bae416f
wip with count of items. We calculate hashes only when necessary
seperman Apr 24, 2020
c9e4b04
fixing little final bugs
seperman Apr 24, 2020
3aff103
those last bugs
seperman Apr 24, 2020
40ae030
yay all tests passing
seperman Apr 25, 2020
1f75538
Merge branch 'deep-ignore-order' into dev
seperman Apr 25, 2020
830f2b2
shuffling docs
seperman Apr 25, 2020
8663b4a
Bump version: 4.3.2 → 5.0.0
seperman Apr 25, 2020
c93a427
no need to deepcopy parameters
seperman Apr 25, 2020
9245f82
better numpy support
seperman Apr 26, 2020
d88ad9c
fixing parameterize_cases for python 3.5 where dict is not sorted
seperman Apr 26, 2020
147389c
better support for numpy
seperman Apr 27, 2020
e285d71
more numpy tests
seperman Apr 27, 2020
4b89f19
adding more delta tests for numpy
seperman Apr 27, 2020
6fa903c
multi dimensional array delta is failing
seperman Apr 27, 2020
1035bed
delta numpy multi dimension arrays are a pain
seperman Apr 27, 2020
56b98ab
fixing a bunch of stuff around report repetition and multi dimensional
seperman Apr 29, 2020
1033c0a
fixing the pytest err comparison test
seperman Apr 29, 2020
a274c4d
wtf pytest
seperman Apr 29, 2020
b759cf6
adding the dump method
seperman Apr 29, 2020
496f195
everyday I'm shuffling
seperman May 1, 2020
d256ab4
adding max_passes
seperman May 2, 2020
0267ded
wip shuffling
seperman May 2, 2020
4e1f53f
yay more accurate report
seperman May 2, 2020
b8d546b
Making the most in common paid finder more deterministic
seperman May 3, 2020
d478e83
adding logger
seperman May 3, 2020
7915454
refactoring docs and fixed a bug with model path
seperman May 5, 2020
98d7d2d
dealing with ignore type in groups
seperman May 5, 2020
85766fb
Handles empty diff when initializing Delta
laike9m May 10, 2020
4892f61
Merge pull request #192 from laike9m/dev
seperman May 11, 2020
e6d1767
major refactor for ignore_order
seperman May 12, 2020
666599e
continous refactor
seperman May 13, 2020
f23e803
what is going on
seperman May 13, 2020
a6f8cb4
adding anyset
seperman May 14, 2020
ee6821d
fixing the tests
seperman May 14, 2020
1c037c4
adding max_diffs
seperman May 14, 2020
dbea77c
increasing the coverage
seperman May 14, 2020
6aaaaa8
moving the API to Delta
seperman May 14, 2020
15d82ed
tests
seperman May 14, 2020
6f003ae
more tests
seperman May 14, 2020
ad7672b
adding get_item for the path module
seperman May 15, 2020
a617e77
adding tests
seperman May 15, 2020
2988c87
Merge branch 'dev' of github.com:seperman/deepdiff into dev
seperman May 15, 2020
69a2237
Merge branch 'ignore-order-dynamic' into dev
seperman May 15, 2020
b33e6a9
docs
seperman May 15, 2020
cff51ee
one test at a time
seperman May 15, 2020
f461609
one test at a time
seperman May 15, 2020
3d46c04
one test at a time
seperman May 15, 2020
ce4959d
Found a bug that could make delta addition get into an infinite loop.
seperman May 15, 2020
f969eaf
adding more tests
seperman May 16, 2020
02b2f4a
fixing tests
seperman May 16, 2020
d1c6281
delta is 100% covered
seperman May 16, 2020
f2b7a0e
diff np from helper
seperman May 16, 2020
3a91682
deepcopy delta per comments by laike9m
seperman May 16, 2020
b46d9e9
testing progress logger
seperman May 16, 2020
5fe6811
adding test for get stats
seperman May 16, 2020
57dbd3b
fixing the bug with default max distance being zero
seperman May 16, 2020
8d082ec
loop is avoided
seperman May 16, 2020
33e6c29
fixing distance cache key
seperman May 17, 2020
e28f555
adding test for deepdiff using sha256
seperman May 17, 2020
919cf47
more test coverage
seperman May 17, 2020
46b84f3
diff moduie is now 100% covered
seperman May 17, 2020
2b1ee0a
more coverage
seperman May 17, 2020
6ccbe02
get deep distance now works even when ignore_order is false
seperman May 17, 2020
efe70be
distance module is covered now
seperman May 17, 2020
15515c1
shuffling distance stuff
seperman May 17, 2020
8fc3ee1
changed the formula for numeric distance
seperman May 17, 2020
73fd3f8
distance module full coverage
seperman May 17, 2020
56b7bac
what has changed. 3 diff tests failing
seperman May 19, 2020
71b4e81
private keys should not be counted towards distance
seperman May 20, 2020
9905016
add truncate_datetime to truncate (optional) datetime objects before …
May 20, 2020
0de93d3
merged with latest origin/dev
May 20, 2020
5c59909
reducing the cache size
seperman May 21, 2020
2e38602
one test multi dimensional array failing
seperman May 27, 2020
d091479
pep8
seperman May 27, 2020
c020c59
the most annoying bug
seperman May 27, 2020
dc85851
fixing for python 3.5
seperman May 27, 2020
092c053
removing print
seperman May 27, 2020
18573f9
it works
seperman May 29, 2020
6b03fa1
adding comments
seperman May 29, 2020
6944ab4
fixing one test
seperman May 29, 2020
ac20bd9
more coverage
seperman May 29, 2020
26dda06
introducing purge
seperman May 29, 2020
12d874a
more coverage
seperman May 29, 2020
4675a5e
fixed path cache
seperman May 29, 2020
6939941
Merge branch 'dev' of github.com:seperman/deepdiff into dev
May 29, 2020
7163bdb
Merge pull request #195 from timson/dev
seperman May 30, 2020
118d022
removing unused stuff
seperman May 30, 2020
7d39922
Merge branch 'dev' of github.com:seperman/deepdiff into dev
seperman May 30, 2020
6f6afc2
fixing docs
seperman May 30, 2020
9da68d1
cover it
seperman May 30, 2020
1aa6be8
more coverage
seperman May 30, 2020
98793d7
getting there on coverage
seperman May 30, 2020
19d74f6
fixing the loop
seperman May 31, 2020
09deaab
distance cache key setting and retrieval is now symmetrical between
seperman May 31, 2020
5b4fc49
enough coverage
seperman May 31, 2020
23ad575
cant wait to drop python 3.5 support
seperman May 31, 2020
5fb4a74
regression in exclude path
seperman May 31, 2020
c642312
adding one more test
seperman Jun 1, 2020
569baa4
fixing tests across python versions.
seperman Jun 1, 2020
5ff3e6c
removing delta header checks
seperman Jun 1, 2020
1c5e4cc
marking lines that only run in py3.5
seperman Jun 1, 2020
a36cb6e
plaing with the cache
seperman Jun 3, 2020
28c566e
setting cache size to zero as default
seperman Jun 5, 2020
8403698
shuffling around the parameters
seperman Jun 5, 2020
40bce63
do these new results make sense?
seperman Jun 6, 2020
6252937
adding tests
seperman Jun 6, 2020
ff35238
setting the tuning sample size to zero
seperman Jun 6, 2020
65e568c
there is a bug with the cache
seperman Jun 8, 2020
e992dda
bye bye level cache
seperman Jun 9, 2020
6fcb3f8
fixing the tests
seperman Jun 9, 2020
e5cb172
removing the last remnants of level cache
seperman Jun 9, 2020
f31faa3
remove commented lines
seperman Jun 9, 2020
8a7692e
pep8
seperman Jun 9, 2020
9347d62
fixing the tests for py3.5
seperman Jun 11, 2020
44521b1
docs
seperman Jun 11, 2020
4ff4654
docs wip
seperman Jun 15, 2020
d24cd01
adding more docs
seperman Jun 15, 2020
8325fe8
adding more docs
seperman Jun 16, 2020
cc3d57f
adding more docs. Removed max_distances_to_keep_track_per_item
seperman Jun 18, 2020
ea833d7
making parameters in alphabetical order
seperman Jun 18, 2020
f1325e3
adding more docs. Almost done.
seperman Jun 19, 2020
d6074cb
more delta docs
seperman Jun 19, 2020
b52efa1
finally the docs are ready
seperman Jun 20, 2020
b531ad2
more docs
seperman Jun 22, 2020
f225d76
reqs
seperman Jun 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Expand Up @@ -63,5 +63,9 @@ target/
.idea/
.~lock*

.python-version
.python-version*

temp*

# env file
.env
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -12,7 +12,7 @@ matrix:
install:
- pip install -r requirements-dev.txt

script: pytest --cov=deepdiff tests/
script: pytest --cov=deepdiff tests/ --runslow

after_success:
- coveralls
10 changes: 8 additions & 2 deletions AUTHORS
@@ -1,8 +1,10 @@
Developer:

- Seperman
- Victor Hahn Castell @ Flexoptix

And many thanks to the following people for their contributions to DeepDiff:
And many thanks to the following people for their contributions to DeepDiff!

- Victor Hahn Castell @ Flexoptix for tree view and major contributions.
- nfvs for Travis-CI setup script.
- brbsix for initial Py3 porting.
- WangFenjin for Unicode support.
Expand All @@ -26,3 +28,7 @@ And many thanks to the following people for their contributions to DeepDiff:
- Hugo (hugovk) for fixes for Python 3.10 and dropping support for EOL Python 3.4
- Andrey Gavrilin (gaal-dev) for hashing classes.
- Ivan Piskunov (van-ess0) for deprecation warning enhancement.
- Nathaniel Brown (nathanielobrown) Adds support for datetime.time
- Michał Karaś (MKaras93) for the pretty view
- Christian Kothe (chkothe) for the basic support for diffing numpy arrays
- Timothy (timson) for truncate_datetime
48 changes: 48 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,48 @@
DeepDiff Change log

- v5-0-0: Introducing the Delta object, Improving Numpy support, Fixing tuples comparison when ignore_order=True, Dramatically improving the results when ignore_order=True by running in passes, Introducing pretty print view, deep_distance, purge, progress logging, cache and truncate_datetime.
- v4-3-3: Adds support for datetime.time
- v4-3-2: Deprecation Warning Enhancement
- v4-3-1: Fixing the issue with exclude_path and hash calculations when dictionaries were inside iterables. https://github.com/seperman/deepdiff/issues/174
- v4-3-0: adding exclude_obj_callback
- v4-2-0: .json property is finally removed. Fix for Py3.10. Dropping support for EOL Python 3.4. Ignoring private keys when calculating hashes. For example __init__ is not a part of hash calculation anymore. Fix for #166 Problem with comparing lists, with an boolean as element.
- v4-0-9: Fixing the bug for hashing custom unhashable objects
- v4-0-8: Adding ignore_nan_inequality for float('nan')
- v4-0-7: Hashing of the number 1 vs. True
- v4-0-6: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround.
- v4-0-5: Fixing number diffing. Adding number_format_notation and number_to_string_func.
- v4-0-4: Adding ignore_string_case and ignore_type_subclasses
- v4-0-3: Adding versionbump tool for release
- v4-0-2: Fixing installation issue where rst files are missing.
- v4-0-1: Fixing installation Tarball missing requirements.txt . DeepDiff v4+ should not show up as pip installable for Py2. Making Murmur3 installation optional.
- v4-0-0: Ending Python 2 support, Adding more functionalities and documentation for DeepHash. Switching to Pytest for testing. Switching to Murmur3 128bit for hashing. Fixing classes which inherit from classes with slots didn't have all of their slots compared. Renaming ContentHash to DeepHash. Adding exclude by path and regex path to DeepHash. Adding ignore_type_in_groups. Adding match_string to DeepSearch. Adding Timedelta object diffing.
- v3-5-0: Exclude regex path
- v3-3-0: Searching for objects and class attributes
- v3-2-2: Adding help(deepdiff)
- v3-2-1: Fixing hash of None
- v3-2-0: Adding grep for search: object | grep(item)
- v3-1-3: Unicode vs. Bytes default fix
- v3-1-2: NotPresent Fix when item is added or removed.
- v3-1-1: Bug fix when item value is None (#58)
- v3-1-0: Serialization to/from json
- v3-0-0: Introducing Tree View
- v2-5-3: Bug fix on logging for content hash.
- v2-5-2: Bug fixes on content hash.
- v2-5-0: Adding ContentHash module to fix ignore_order once and for all.
- v2-1-0: Adding Deep Search. Now you can search for item in an object.
- v2-0-0: Exclusion patterns better coverage. Updating docs.
- v1-8-0: Exclusion patterns.
- v1-7-0: Deep Set comparison.
- v1-6-0: Unifying key names. i.e newvalue is new_value now. For backward compatibility, newvalue still works.
- v1-5-0: Fixing ignore order containers with unordered items. Adding significant digits when comparing decimals. Changes property is deprecated.
- v1-1-0: Changing Set, Dictionary and Object Attribute Add/Removal to be reported as Set instead of List. Adding Pypy compatibility.
- v1-0-2: Checking for ImmutableMapping type instead of dict
- v1-0-1: Better ignore order support
- v1-0-0: Restructuring output to make it more useful. This is NOT backward compatible.
- v0-6-1: Fixiing iterables with unhashable when order is ignored
- v0-6-0: Adding unicode support
- v0-5-9: Adding decimal support
- v0-5-8: Adding ignore order of unhashables support
- v0-5-7: Adding ignore order support
- v0-5-6: Adding slots support
- v0-5-5: Adding loop detection
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 - 2016 Sep Ehr (Seperman) and contributors
Copyright (c) 2014 - 2020 Sep Dehpour (Seperman) and contributors
www.zepworks.com

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
@@ -1,5 +1,6 @@
include LICENSE
include AUTHORS
include CHANGELOG
include *.rst
include deepdiff/*.rst
include *.txt
Expand Down
62 changes: 14 additions & 48 deletions README.md
@@ -1,4 +1,4 @@
# DeepDiff v 4.3.2
# DeepDiff v 5.0.0

<!-- ![Downloads](https://img.shields.io/pypi/dm/deepdiff.svg?style=flat) -->
![Python Versions](https://img.shields.io/pypi/pyversions/deepdiff.svg?style=flat)
Expand Down Expand Up @@ -47,6 +47,7 @@ DeepDiff gets the difference of 2 objects.

> - Please take a look at the [DeepDiff docs](deepdiff/diff_doc.rst)
> - The full documentation can be found on <https://deepdiff.readthedocs.io>
> - Tutorials can be found on <https://zepworks.com/tags/deepdiff/>

## A few Examples

Expand Down Expand Up @@ -417,50 +418,7 @@ And then running

# ChangeLog

- v4-3-2: Deprecation Warning Enhancement
- v4-3-1: Fixing the issue with exclude_path and hash calculations when dictionaries were inside iterables. https://github.com/seperman/deepdiff/issues/174
- v4-3-0: adding exclude_obj_callback
- v4-2-0: .json property is finally removed. Fix for Py3.10. Dropping support for EOL Python 3.4. Ignoring private keys when calculating hashes. For example __init__ is not a part of hash calculation anymore. Fix for #166 Problem with comparing lists, with an boolean as element.
- v4-0-9: Fixing the bug for hashing custom unhashable objects
- v4-0-8: Adding ignore_nan_inequality for float('nan')
- v4-0-7: Hashing of the number 1 vs. True
- v4-0-6: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround.
- v4-0-5: Fixing number diffing. Adding number_format_notation and number_to_string_func.
- v4-0-4: Adding ignore_string_case and ignore_type_subclasses
- v4-0-3: Adding versionbump tool for release
- v4-0-2: Fixing installation issue where rst files are missing.
- v4-0-1: Fixing installation Tarball missing requirements.txt . DeepDiff v4+ should not show up as pip installable for Py2. Making Murmur3 installation optional.
- v4-0-0: Ending Python 2 support, Adding more functionalities and documentation for DeepHash. Switching to Pytest for testing. Switching to Murmur3 128bit for hashing. Fixing classes which inherit from classes with slots didn't have all of their slots compared. Renaming ContentHash to DeepHash. Adding exclude by path and regex path to DeepHash. Adding ignore_type_in_groups. Adding match_string to DeepSearch. Adding Timedelta object diffing.
- v3-5-0: Exclude regex path
- v3-3-0: Searching for objects and class attributes
- v3-2-2: Adding help(deepdiff)
- v3-2-1: Fixing hash of None
- v3-2-0: Adding grep for search: object | grep(item)
- v3-1-3: Unicode vs. Bytes default fix
- v3-1-2: NotPresent Fix when item is added or removed.
- v3-1-1: Bug fix when item value is None (#58)
- v3-1-0: Serialization to/from json
- v3-0-0: Introducing Tree View
- v2-5-3: Bug fix on logging for content hash.
- v2-5-2: Bug fixes on content hash.
- v2-5-0: Adding ContentHash module to fix ignore_order once and for all.
- v2-1-0: Adding Deep Search. Now you can search for item in an object.
- v2-0-0: Exclusion patterns better coverage. Updating docs.
- v1-8-0: Exclusion patterns.
- v1-7-0: Deep Set comparison.
- v1-6-0: Unifying key names. i.e newvalue is new_value now. For backward compatibility, newvalue still works.
- v1-5-0: Fixing ignore order containers with unordered items. Adding significant digits when comparing decimals. Changes property is deprecated.
- v1-1-0: Changing Set, Dictionary and Object Attribute Add/Removal to be reported as Set instead of List. Adding Pypy compatibility.
- v1-0-2: Checking for ImmutableMapping type instead of dict
- v1-0-1: Better ignore order support
- v1-0-0: Restructuring output to make it more useful. This is NOT backward compatible.
- v0-6-1: Fixiing iterables with unhashable when order is ignored
- v0-6-0: Adding unicode support
- v0-5-9: Adding decimal support
- v0-5-8: Adding ignore order of unhashables support
- v0-5-7: Adding ignore order support
- v0-5-6: Adding slots support
- v0-5-5: Adding loop detection
Please take a look at the [changelog](changelog.md) file.

# Releases

Expand All @@ -475,21 +433,28 @@ git push && git push --tags
# Contribute

1. Please make your PR against the dev branch
2. Please make sure that your PR has tests. Since DeepDiff is used in many sensitive data driven projects, we maintain 100% test coverage on the code. There are occasiannly exceptions to that rule but that is rare.
2. Please make sure that your PR has tests. Since DeepDiff is used in many sensitive data driven projects, we strive to maintain around 100% test coverage on the code.

Please run `pytest --cov=deepdiff` to see the coverage report.

Or to see a more user friendly version, please run: `pytest --cov=deepdiff --cov-report term-missing`.

Thank you!

# Authors

Developer:

- Seperman (Sep Dehpour)
- [Github](https://github.com/seperman)
- [Linkedin](http://www.linkedin.com/in/sepehr)
- [ZepWorks](http://www.zepworks.com)

- Victor Hahn Castell for major contributions
And many thanks to the following people for their contributions to DeepDiff!

- Victor Hahn Castell for the tree view and major contributions:
- [hahncastell.de](http://hahncastell.de)
- [flexoptix.net](http://www.flexoptix.net)

- nfvs for Travis-CI setup script.
- brbsix for initial Py3 porting.
- WangFenjin for unicode support.
Expand All @@ -512,3 +477,4 @@ Thank you!
- Necrophagos for Hashing of the number 1 vs. True
- gaal-dev for adding exclude_obj_callback
- Ivan Piskunov (van-ess0) for deprecation warning enhancement.
- Michał Karaś (MKaras93) for the pretty view
60 changes: 60 additions & 0 deletions conftest.py
@@ -1,4 +1,64 @@
import sys
import os
import json
import pytest

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'tests')))

FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'tests/fixtures/')


def pytest_addoption(parser):
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
)


def pytest_configure(config):
config.addinivalue_line("markers", "slow: mark test as slow to run")


def pytest_collection_modifyitems(config, items):
if config.getoption("--runslow"):
# --runslow given in cli: do not skip slow tests
return
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)


@pytest.fixture(scope='class')
def nested_a_t1():
with open(os.path.join(FIXTURES_DIR, 'nested_a_t1.json')) as the_file:
return json.load(the_file)


@pytest.fixture(scope='class')
def nested_a_t2():
with open(os.path.join(FIXTURES_DIR, 'nested_a_t2.json')) as the_file:
return json.load(the_file)


@pytest.fixture(scope='class')
def nested_a_result():
with open(os.path.join(FIXTURES_DIR, 'nested_a_result.json')) as the_file:
return json.load(the_file)


@pytest.fixture(scope='class')
def nested_b_t1():
with open(os.path.join(FIXTURES_DIR, 'nested_b_t1.json')) as the_file:
return json.load(the_file)


@pytest.fixture(scope='class')
def nested_b_t2():
with open(os.path.join(FIXTURES_DIR, 'nested_b_t2.json')) as the_file:
return json.load(the_file)


@pytest.fixture(scope='class')
def nested_b_result():
with open(os.path.join(FIXTURES_DIR, 'nested_b_result.json')) as the_file:
return json.load(the_file)
6 changes: 4 additions & 2 deletions deepdiff/__init__.py
@@ -1,6 +1,6 @@
"""This module offers the DeepDiff, DeepSearch, grep and DeepHash classes."""
"""This module offers the DeepDiff, DeepSearch, grep, Delta and DeepHash classes."""
# flake8: noqa
__version__ = '4.3.2'
__version__ = '5.0.0'
import logging

if __name__ == '__main__':
Expand All @@ -10,3 +10,5 @@
from .diff import DeepDiff
from .search import DeepSearch, grep
from .deephash import DeepHash
from .delta import Delta
from .path import extract
66 changes: 66 additions & 0 deletions deepdiff/anyset.py
@@ -0,0 +1,66 @@
from ordered_set import OrderedSet
from deepdiff.deephash import DeepHash
from deepdiff.helper import dict_


class AnySet:
"""
Any object can be in this set whether hashable or not.
Note that the current implementation has memory leak and keeps
traces of objects in itself even after popping.
However one the AnySet object is deleted, all those traces will be gone too.
"""
def __init__(self, items=None):
self._set = OrderedSet()
self._hashes = dict_()
self._hash_to_objects = dict_()
if items:
for item in items:
self.add(item)

def add(self, item):
try:
self._set.add(item)
except TypeError:
hashes_obj = DeepHash(item, hashes=self._hashes)
hash_ = hashes_obj[item]
if hash_ not in self._hash_to_objects:
self._hash_to_objects[hash_] = item

def __contains__(self, item):
try:
result = item in self._set
except TypeError:
hashes_obj = DeepHash(item, hashes=self._hashes)
hash_ = hashes_obj[item]
result = hash_ in self._hash_to_objects
return result

def pop(self):
if self._set:
return self._set.pop()
else:
return self._hash_to_objects.pop(next(iter(self._hash_to_objects)))

def __eq__(self, other):
set_part, hashes_to_objs_part = other
return (self._set == set_part and self._hash_to_objects == hashes_to_objs_part)

__req__ = __eq__

def __repr__(self):
return "< AnySet {}, {} >".format(self._set, self._hash_to_objects)

__str__ = __repr__

def __len__(self):
return len(self._set) + len(self._hash_to_objects)

def __iter__(self):
for item in self._set:
yield item
for item in self._hash_to_objects.values():
yield item

def __bool__(self):
return bool(self._set or self._hash_to_objects)
1 change: 1 addition & 0 deletions deepdiff/base.py
Expand Up @@ -3,6 +3,7 @@


DEFAULT_SIGNIFICANT_DIGITS_WHEN_IGNORE_NUMERIC_TYPES = 12
TYPE_STABILIZATION_MSG = 'Unable to stabilize the Numpy array {} due to {}. Please set ignore_order=False.'


class Base:
Expand Down