Skip to content

Commit 9bdcf8c

Browse files
committed
updating docs
1 parent 5ac42b7 commit 9bdcf8c

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ With the introduction of `threshold_to_diff_deeper`, the values returned are dif
3333
- [x] Added `use_log_scale:bool` and `log_scale_similarity_threshold:float`. They can be used to ignore small changes in numbers by comparing their differences in logarithmic space. This is different than ignoring the difference based on significant digits.
3434
- [x] json serialization of reversed lists.
3535
- [x] Fix for iterable moved items when `iterable_compare_func` is used.
36-
- [x] Pandas and Polars support
36+
- [x] Pandas and Polars support.
3737

3838
DeepDiff 7-0-1
3939

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
# General information about the project.
5555
project = 'DeepDiff'
56-
copyright = '2015-2023, Sep Dehpour'
56+
copyright = '2015-2024, Sep Dehpour'
5757
author = 'Sep Dehpour'
5858

5959
# The version info for the project you're documenting, acts as replacement for

docs/faq.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@ Bump up these 2 parameters to 1 and you get what you want:
6060
'old_value': 'somevalue1'}}}
6161

6262

63+
Q: The report of changes in a nested dictionary is too granular
64+
---------------------------------------------------------------
65+
66+
**Answer**
67+
68+
Use :ref:`threshold_to_diff_deeper_label`
69+
70+
>>> from deepdiff import DeepDiff
71+
>>> t1 = {"veggie": "carrots"}
72+
>>> t2 = {"meat": "carrots"}
73+
>>>
74+
>>> DeepDiff(t1, t2, threshold_to_diff_deeper=0)
75+
{'dictionary_item_added': ["root['meat']"], 'dictionary_item_removed': ["root['veggie']"]}
76+
>>> DeepDiff(t1, t2, threshold_to_diff_deeper=0.33)
77+
{'values_changed': {'root': {'new_value': {'meat': 'carrots'}, 'old_value': {'veggie': 'carrots'}}}}
78+
79+
80+
6381
Q: TypeError: Object of type type is not JSON serializable
6482
----------------------------------------------------------
6583

@@ -107,6 +125,28 @@ Use parse_path:
107125
>>> parse_path("root['joe'].age", include_actions=True)
108126
[{'element': 'joe', 'action': 'GET'}, {'element': 'age', 'action': 'GETATTR'}]
109127

128+
Or use the tree view so you can use path(output_format='list'):
129+
130+
>>> t1 = {1:1, 2:2, 3:3, 4:{"a":"hello", "b":[1, 2, 3, 4]}}
131+
>>> t2 = {1:1, 2:2, 3:3, 4:{"a":"hello", "b":[1, 2]}}
132+
>>> ddiff = DeepDiff(t1, t2, view='tree')
133+
>>> ddiff
134+
{'iterable_item_removed': [<root[4]['b'][2] t1:3, t2:not present>, <root[4]['b'][3] t1:4, t2:not present>]}
135+
>>> # Note that the iterable_item_removed is a set. In this case it has 2 items in it.
136+
>>> # One way to get one item from the set is to convert it to a list
137+
>>> # And then get the first item of the list:
138+
>>> removed = list(ddiff['iterable_item_removed'])[0]
139+
>>> removed
140+
<root[4]['b'][2] t1:3, t2:not present>
141+
>>>
142+
>>> parent = removed.up
143+
>>> parent
144+
<root[4]['b'] t1:[1, 2, 3, 4], t2:[1, 2]>
145+
>>> parent.path() # gives you the string representation of the path
146+
"root[4]['b']"
147+
>>> parent.path(output_format='list') # gives you the list of keys and attributes that make up the path
148+
[4, 'b']
149+
110150

111151
---------
112152

0 commit comments

Comments
 (0)