Skip to content

Commit

Permalink
updating authors and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
seperman committed Oct 13, 2021
1 parent ba10371 commit 199abc3
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 4 deletions.
6 changes: 5 additions & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ Authors in order of the contributions:
- Tim Klein [timjklein36](https://github.com/timjklein36) for retaining the order of multiple dictionary items added via Delta.
- Wilhelm Schürmann[wbsch](https://github.com/wbsch) for fixing the typo with yml files.
- [lyz-code](https://github.com/lyz-code) for adding support for regular expressions in DeepSearch and strict_checking feature in DeepSearch.
- [dtorres-sf](https://github.com/dtorres-sf)for adding the option for custom compare function
- [dtorres-sf](https://github.com/dtorres-sf) for adding the option for custom compare function
- Tony Wang [Tony-Wang](https://github.com/Tony-Wang) for bugfix: verbose_level==0 should disable values_changes.
- Sun Ao [eggachecat](https://github.com/eggachecat) for adding custom operators.
- Sun Ao [eggachecat](https://github.com/eggachecat) for adding ignore_order_func.
- [SlavaSkvortsov](https://github.com/SlavaSkvortsov) for fixing unprocessed key error.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# DeepDiff Change log

- v5-6-0: Adding custom operators, and ignore_order_func. Bugfix: verbose_level==0 should disable values_changes. Bugfix: unprocessed key error.
- v5-5-0: adding iterable_compare_func for DeepDiff, adding output_format of list for path() in tree view.
- v5-4-0: adding strict_checking for numbers in DeepSearch.
- v5-3-0: add support for regular expressions in DeepSearch.
Expand Down
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,44 @@ Tested on Python 3.6+ and PyPy3.

## What is new?

Deepdiff 5.6.0 comes with regular expressions in the DeepSearch and grep modules:
DeepDiff 5-6-0 allows you to pass custom operators.

```python
>>> from deepdiff import DeepDiff
>>> from deepdiff.operator import BaseOperator
>>> class CustomClass:
... def __init__(self, d: dict, l: list):
... self.dict = d
... self.dict['list'] = l
...
>>>
>>> custom1 = CustomClass(d=dict(a=1, b=2), l=[1, 2, 3])
>>> custom2 = CustomClass(d=dict(c=3, d=4), l=[1, 2, 3, 2])
>>> custom3 = CustomClass(d=dict(a=1, b=2), l=[1, 2, 3, 4])
>>>
>>>
>>> class ListMatchOperator(BaseOperator):
... def give_up_diffing(self, level, diff_instance):
... if set(level.t1.dict['list']) == set(level.t2.dict['list']):
... return True
...
>>>
>>> DeepDiff(custom1, custom2, custom_operators=[
... ListMatchOperator(types=[CustomClass])
... ])
{}
>>>
>>>
>>> DeepDiff(custom2, custom3, custom_operators=[
... ListMatchOperator(types=[CustomClass])
... ])
{'dictionary_item_added': [root.dict['a'], root.dict['b']], 'dictionary_item_removed': [root.dict['c'], root.dict['d']], 'values_changed': {"root.dict['list'][3]": {'new_value': 4, 'old_value': 2}}}
>>>

```


Deepdiff 5-5-0 comes with regular expressions in the DeepSearch and grep modules:

```python
>>> from deepdiff import grep
Expand Down
3 changes: 3 additions & 0 deletions docs/diff_doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ ignore_order : Boolean, default=False
Normally ignore_order does not report duplicates and repetition changes.
In order to report repetitions, set report_repetition=True in addition to ignore_order=True

ignore_order_func : Function, default=None
:ref:`ignore_order_func_label` Sometimes single *ignore_order* parameter is not enough to do a diff job,
you can use *ignore_order_func* to determine whether the order of certain paths should be ignored

ignore_string_type_changes: Boolean, default = False
:ref:`ignore_string_type_changes_label`
Expand Down
14 changes: 14 additions & 0 deletions docs/ignore_order.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ List difference ignoring order with *ignore_order_func*
{ 'values_changed': { "root['list'][0]": {'new_value': 3, 'old_value': 1},
"root['list'][2]": {'new_value': 1, 'old_value': 3}}}


Ignoring order when certain word in the path
>>> from deepdiff import DeepDiff
>>> t1 = {'a': [1, 2], 'b': [3, 4]}
>>> t2 = {'a': [2, 1], 'b': [4, 3]}
>>> DeepDiff(t1, t2, ignore_order=True)
{}
>>> def ignore_order_func(level):
... return 'a' in level.path()
...
>>> DeepDiff(t1, t2, ignore_order=True, ignore_order_func=ignore_order_func)
{'values_changed': {"root['b'][0]": {'new_value': 4, 'old_value': 3}, "root['b'][1]": {'new_value': 3, 'old_value': 4}}}


.. _report_repetition_label:

Reporting Repetitions
Expand Down
43 changes: 41 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,54 @@ The DeepDiff library includes the following modules:
Supported Python Versions
*************************

DeepDiff is rigorously tested against Python 3.6, 3.7, 3.8, 3.9 and Pypy3
DeepDiff is rigorously tested against Python 3.6 up to 3.10 and Pypy3

NOTE: Python 2 is not supported any more. DeepDiff v3.3.0 was the last version to supprt Python 2.

***********
What is New
***********

New In DeepDiff 5.6.0
## What is new?

New In DeepDiff 5-6-0
---------------------

Create custom operators!

>>> from deepdiff import DeepDiff
>>> from deepdiff.operator import BaseOperator
>>> class CustomClass:
... def __init__(self, d: dict, l: list):
... self.dict = d
... self.dict['list'] = l
...
>>>
>>> custom1 = CustomClass(d=dict(a=1, b=2), l=[1, 2, 3])
>>> custom2 = CustomClass(d=dict(c=3, d=4), l=[1, 2, 3, 2])
>>> custom3 = CustomClass(d=dict(a=1, b=2), l=[1, 2, 3, 4])
>>>
>>>
>>> class ListMatchOperator(BaseOperator):
... def give_up_diffing(self, level, diff_instance):
... if set(level.t1.dict['list']) == set(level.t2.dict['list']):
... return True
...
>>>
>>> DeepDiff(custom1, custom2, custom_operators=[
... ListMatchOperator(types=[CustomClass])
... ])
{}
>>>
>>>
>>> DeepDiff(custom2, custom3, custom_operators=[
... ListMatchOperator(types=[CustomClass])
... ])
{'dictionary_item_added': [root.dict['a'], root.dict['b']], 'dictionary_item_removed': [root.dict['c'], root.dict['d']], 'values_changed': {"root.dict['list'][3]": {'new_value': 4, 'old_value': 2}}}
>>>


New In DeepDiff 5-5-0
---------------------

1. New option called `iterable_compare_func` that takes a function pointer to compare two items. The function takes three parameters (x, y, level) and should return `True` if it is a match, `False` if it is not a match or raise `CannotCompare` if it is unable to compare the two. If `CannotCompare` is raised then it will revert back to comparing in order. If `iterable_compare_func` is not provided or set to None the behavior defaults to comparing items in order. A new report item called `iterable_item_moved` this will only ever be added if there is a custom compare function.
Expand Down

0 comments on commit 199abc3

Please sign in to comment.