Skip to content

Commit 9b70b2b

Browse files
authored
Merge pull request #314 from seperman/dev
5.8.1
2 parents 9486037 + e3c2ba1 commit 9b70b2b

File tree

12 files changed

+240
-34
lines changed

12 files changed

+240
-34
lines changed

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DeepDiff v 5.8.0
1+
# DeepDiff v 5.8.1
22

33
![Downloads](https://img.shields.io/pypi/dm/deepdiff.svg?style=flat)
44
![Python Versions](https://img.shields.io/pypi/pyversions/deepdiff.svg?style=flat)
@@ -14,10 +14,16 @@
1414

1515
Tested on Python 3.6+ and PyPy3.
1616

17-
- **[Documentation](https://zepworks.com/deepdiff/5.8.0/)**
17+
- **[Documentation](https://zepworks.com/deepdiff/5.8.1/)**
1818

1919
## What is new?
2020

21+
DeepDiff 5-8-1 includes bug fixes:
22+
- Fixed test suite for 32bit systems (https://github.com/seperman/deepdiff/issues/302) by [Louis-Philippe Véronneau](https://github.com/baldurmen)
23+
- Fixed the issue when using `ignore_order=True` and `group_by` simultaneously
24+
- Added the support for diffing object properties (`@property`) (https://github.com/seperman/deepdiff/issues/312)
25+
- Better support of diffing private variables
26+
2127
DeepDiff 5-8-0 includes bug fixes and improvements:
2228

2329
- Fixed the bug with delta randomly not producing the same results when `ignore_order=True` (https://github.com/seperman/deepdiff/issues/277)
@@ -61,13 +67,13 @@ Note: if you want to use DeepDiff via commandline, make sure to run `pip install
6167

6268
DeepDiff gets the difference of 2 objects.
6369

64-
> - Please take a look at the [DeepDiff docs](https://zepworks.com/deepdiff/5.8.0/diff.html)
65-
> - The full documentation of all modules can be found on <https://zepworks.com/deepdiff/5.8.0/>
70+
> - Please take a look at the [DeepDiff docs](https://zepworks.com/deepdiff/5.8.1/diff.html)
71+
> - The full documentation of all modules can be found on <https://zepworks.com/deepdiff/5.8.1/>
6672
> - Tutorials and posts about DeepDiff can be found on <https://zepworks.com/tags/deepdiff/>
6773
6874
## A few Examples
6975

70-
> Note: This is just a brief overview of what DeepDiff can do. Please visit <https://zepworks.com/deepdiff/5.8.0/> for full documentation.
76+
> Note: This is just a brief overview of what DeepDiff can do. Please visit <https://zepworks.com/deepdiff/5.8.1/> for full documentation.
7177
7278
### List difference ignoring order or duplicates
7379

@@ -271,8 +277,8 @@ Example:
271277
```
272278

273279

274-
> - Please take a look at the [DeepDiff docs](https://zepworks.com/deepdiff/5.8.0/diff.html)
275-
> - The full documentation can be found on <https://zepworks.com/deepdiff/5.8.0/>
280+
> - Please take a look at the [DeepDiff docs](https://zepworks.com/deepdiff/5.8.1/diff.html)
281+
> - The full documentation can be found on <https://zepworks.com/deepdiff/5.8.1/>
276282
277283

278284
# Deep Search
@@ -304,17 +310,17 @@ And you can pass all the same kwargs as DeepSearch to grep too:
304310
{'matched_paths': {"root['somewhere']": 'around'}, 'matched_values': {"root['long']": 'somewhere'}}
305311
```
306312

307-
> - Please take a look at the [DeepSearch docs](https://zepworks.com/deepdiff/5.8.0/dsearch.html)
308-
> - The full documentation can be found on <https://zepworks.com/deepdiff/5.8.0/>
313+
> - Please take a look at the [DeepSearch docs](https://zepworks.com/deepdiff/5.8.1/dsearch.html)
314+
> - The full documentation can be found on <https://zepworks.com/deepdiff/5.8.1/>
309315
310316
# Deep Hash
311317
(New in v4-0-0)
312318

313319
DeepHash is designed to give you hash of ANY python object based on its contents even if the object is not considered hashable!
314320
DeepHash is supposed to be deterministic in order to make sure 2 objects that contain the same data, produce the same hash.
315321

316-
> - Please take a look at the [DeepHash docs](https://zepworks.com/deepdiff/5.8.0/deephash.html)
317-
> - The full documentation can be found on <https://zepworks.com/deepdiff/5.8.0/>
322+
> - Please take a look at the [DeepHash docs](https://zepworks.com/deepdiff/5.8.1/deephash.html)
323+
> - The full documentation can be found on <https://zepworks.com/deepdiff/5.8.1/>
318324
319325
Let's say you have a dictionary object.
320326

@@ -362,8 +368,8 @@ Which you can write as:
362368
At first it might seem weird why DeepHash(obj)[obj] but remember that DeepHash(obj) is a dictionary of hashes of all other objects that obj contains too.
363369

364370

365-
> - Please take a look at the [DeepHash docs](https://zepworks.com/deepdiff/5.8.0/deephash.html)
366-
> - The full documentation can be found on <https://zepworks.com/deepdiff/5.8.0/>
371+
> - Please take a look at the [DeepHash docs](https://zepworks.com/deepdiff/5.8.1/deephash.html)
372+
> - The full documentation can be found on <https://zepworks.com/deepdiff/5.8.1/>
367373
368374

369375
# Using DeepDiff in unit tests
@@ -443,11 +449,11 @@ Thank you!
443449

444450
How to cite this library (APA style):
445451

446-
Dehpour, S. (2022). DeepDiff (Version 5.8.0) [Software]. Available from https://github.com/seperman/deepdiff.
452+
Dehpour, S. (2022). DeepDiff (Version 5.8.1) [Software]. Available from https://github.com/seperman/deepdiff.
447453

448454
How to cite this library (Chicago style):
449455

450-
Dehpour, Sep. 2022. DeepDiff (version 5.8.0).
456+
Dehpour, Sep. 2022. DeepDiff (version 5.8.1).
451457

452458
# Authors
453459

deepdiff/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""This module offers the DeepDiff, DeepSearch, grep, Delta and DeepHash classes."""
22
# flake8: noqa
3-
__version__ = '5.8.0'
3+
__version__ = '5.8.1'
44
import logging
55

66
if __name__ == '__main__':

deepdiff/diff.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
type_is_subclass_of_type_group, type_in_type_group, get_doc,
2121
number_to_string, datetime_normalize, KEY_TO_VAL_STR, booleans,
2222
np_ndarray, get_numpy_ndarray_rows, OrderedSetPlus, RepeatedTimer,
23-
TEXT_VIEW, TREE_VIEW, DELTA_VIEW,
23+
TEXT_VIEW, TREE_VIEW, DELTA_VIEW, detailed__dict__,
2424
np, get_truncate_datetime, dict_, CannotCompare)
2525
from deepdiff.serialization import SerializationMixin
2626
from deepdiff.distance import DistanceMixin
@@ -231,6 +231,7 @@ def __init__(self,
231231
self.progress_logger = progress_logger
232232
self.cache_size = cache_size
233233
_parameters = self.__dict__.copy()
234+
_parameters['group_by'] = None # overwriting since these parameters will be passed on to other passes.
234235

235236
# Non-Root
236237
if _shared_parameters:
@@ -393,8 +394,8 @@ def _diff_obj(self, level, parents_ids=frozenset(),
393394
t1 = level.t1._asdict()
394395
t2 = level.t2._asdict()
395396
else:
396-
t1 = level.t1.__dict__
397-
t2 = level.t2.__dict__
397+
t1 = detailed__dict__(level.t1, ignore_private_variables=self.ignore_private_variables)
398+
t2 = detailed__dict__(level.t2, ignore_private_variables=self.ignore_private_variables)
398399
except AttributeError:
399400
try:
400401
t1 = self._dict_from_slots(level.t1)

deepdiff/helper.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,3 +582,23 @@ def get_homogeneous_numpy_compatible_type_of_seq(seq):
582582
return PYTHON_TYPE_TO_NUMPY_TYPE.get(type_, False)
583583
else:
584584
return False
585+
586+
587+
def detailed__dict__(obj, ignore_private_variables=True):
588+
"""
589+
Get the detailed dictionary of an object.
590+
591+
This is used so we retrieve object properties too.
592+
"""
593+
result = obj.__dict__.copy() # A shallow copy
594+
private_var_prefix = f"_{obj.__class__.__name__}__" # The semi private variables in Python get this prefix
595+
for key in dir(obj):
596+
if key not in result and (
597+
not ignore_private_variables or (
598+
ignore_private_variables and not key.startswith('__') and not key.startswith(private_var_prefix)
599+
)
600+
):
601+
value = getattr(obj, key)
602+
if not callable(value):
603+
result[key] = value
604+
return result

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
# built documents.
6161
#
6262
# The short X.Y version.
63-
version = '5.8.0'
63+
version = '5.8.1'
6464
# The full version, including alpha/beta/rc tags.
65-
release = '5.8.0'
65+
release = '5.8.1'
6666

6767
load_dotenv(override=True)
6868
DOC_VERSION = os.environ.get('DOC_VERSION', version)

docs/deephash_doc.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ truncate_datetime: string, default = None
149149
If your object is nested, it will build hashes of all the objects it contains too.
150150

151151

152+
.. note::
153+
DeepHash output is not like conventional hash functions. It is a dictionary of object IDs to their hashes. This happens because DeepHash calculates the hash of the object and any other objects found within the object in a recursive manner. If you only need the hash of the object you are passing, all you need to do is to do:
154+
155+
>>> DeepHash(obj)[obj]
156+
157+
152158
**Examples**
153159

154160
Let's say you have a dictionary object.

docs/index.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
contain the root `toctree` directive.
55
66
7-
DeepDiff 5.8.0 documentation!
7+
DeepDiff 5.8.1 documentation!
88
=============================
99

1010
*****************
@@ -31,6 +31,19 @@ The DeepDiff library includes the following modules:
3131
What is New
3232
***********
3333

34+
New In DeepDiff 5-8-1
35+
---------------------
36+
37+
DeepDiff 5-8-1 includes bug fixes: - Fixed test suite for 32bit systems
38+
(https://github.com/seperman/deepdiff/issues/302) by `Louis-Philippe
39+
Véronneau`_ - Fixed the issue when using ``ignore_order=True`` and
40+
``group_by`` simultaneously - Added the support for diffing object
41+
properties (``@property``)
42+
(https://github.com/seperman/deepdiff/issues/312) - Better support of
43+
diffing private variables
44+
45+
.. _Louis-Philippe Véronneau: https://github.com/baldurmen
46+
3447
New In DeepDiff 5-8-0
3548
---------------------
3649

@@ -45,13 +58,6 @@ DeepDiff 5-8-0 includes bug fixes and improvements:
4558
- Fixed TypeError is thrown when comparing bool and str
4659

4760

48-
New In DeepDiff 5-7-0
49-
---------------------
50-
51-
- https://github.com/seperman/deepdiff/pull/284 Bug-Fix: TypeError in _get_numbers_distance() when ignore_order = True by @Dhanvantari
52-
- https://github.com/seperman/deepdiff/pull/280 Add support for UUIDs by @havardthom
53-
- Major bug in delta when it comes to iterable items added or removed is investigated by @uwefladrich and resolved by @seperman
54-
5561
*********
5662
Tutorials
5763
*********

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 5.8.0
2+
current_version = 5.8.1
33
commit = True
44
tag = True
55
tag_name = {new_version}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if os.environ.get('USER', '') == 'vagrant':
1111
del os.link
1212

13-
version = '5.8.0'
13+
version = '5.8.1'
1414

1515

1616
def get_reqs(filename):

tests/test_delta.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import io
44
import json
5+
import sys
56
from decimal import Decimal
67
from unittest import mock
78
from deepdiff import Delta, DeepDiff
@@ -1054,7 +1055,7 @@ def test_ignore_order_delta_cases(
10541055
'root[5]': 10
10551056
},
10561057
'_numpy_paths': {
1057-
'root': 'int64'
1058+
'root': np.where((sys.maxsize > 2**32), 'int64', 'int32')
10581059
}
10591060
},
10601061
'expected_result': 't2'

tests/test_diff_text.py

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44
import logging
55
import uuid
6+
import numpy as np
67
from decimal import Decimal
78
from deepdiff import DeepDiff
89
from deepdiff.helper import pypy3
@@ -569,7 +570,15 @@ class MyEnum(Enum):
569570
'root._value_': {
570571
'old_value': 1,
571572
'new_value': 2
572-
}
573+
},
574+
'root.name': {
575+
'old_value': 'A',
576+
'new_value': 'B'
577+
},
578+
'root.value': {
579+
'old_value': 1,
580+
'new_value': 2
581+
},
573582
}
574583
}
575584
assert ddiff == result
@@ -1594,3 +1603,57 @@ def test_datetime_in_key(self):
15941603
expected = {'values_changed': {f'root[{repr(now)}]': {'new_value': 2, 'old_value': 1}}}
15951604

15961605
assert expected == diff
1606+
1607+
def test_property_values(self):
1608+
1609+
class A:
1610+
_thing = 0
1611+
1612+
def __init__(self, a):
1613+
self.a = a
1614+
1615+
@property
1616+
def thing(self):
1617+
A._thing += 1
1618+
return A._thing
1619+
1620+
@property
1621+
def __thing2(self):
1622+
A._thing += 1
1623+
return A._thing
1624+
1625+
diff = DeepDiff(A(1), A(1))
1626+
expected = {
1627+
'values_changed': {
1628+
'root._thing': {
1629+
'new_value': 1,
1630+
'old_value': 0
1631+
},
1632+
'root.thing': {
1633+
'new_value': 2,
1634+
'old_value': 1
1635+
}
1636+
}
1637+
}
1638+
1639+
assert expected == diff
1640+
1641+
diff2 = DeepDiff(A(1), A(1), ignore_private_variables=False)
1642+
expected2 = {
1643+
'values_changed': {
1644+
'root._A__thing2': {
1645+
'new_value': 5,
1646+
'old_value': 3
1647+
},
1648+
'root._thing': {
1649+
'new_value': 5,
1650+
'old_value': 3
1651+
},
1652+
'root.thing': {
1653+
'new_value': 6,
1654+
'old_value': 4
1655+
}
1656+
}
1657+
}
1658+
1659+
assert expected2 == diff2

0 commit comments

Comments
 (0)