Skip to content

Commit

Permalink
Updating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
seperman committed Oct 4, 2023
1 parent 56cc461 commit 96badc7
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ Authors in order of the timeline of their contributions:
- [kor4ik](https://github.com/kor4ik) for the bugfix for `include_paths` for nested dictionaries.
- [martin-kokos](https://github.com/martin-kokos) for using tomli and tomli-w for dealing with tomli files.
- [Alex Sauer-Budge](https://github.com/amsb) for the bugfix for `datetime.date`.
- [William Jamieson](https://github.com/WilliamJamieson) for [NumPy 2.0 compatibility](https://github.com/seperman/deepdiff/pull/422)
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Tested on Python 3.7+ and PyPy3.

Please check the [ChangeLog](CHANGELOG.md) file for the detailed information.

DeepDiff 6-6-0

- [Serialize To Flat Dicts]()
- [NumPy 2.0 compatibility](https://github.com/seperman/deepdiff/pull/422) by [William Jamieson](https://github.com/WilliamJamieson)

DeepDiff 6-5-0

- [parse_path](https://zepworks.com/deepdiff/current/faq.html#q-how-do-i-parse-deepdiff-result-paths)
Expand Down Expand Up @@ -66,10 +71,21 @@ Install optional packages:

Please take a look at the [CHANGELOG](CHANGELOG.md) file.

# 🛠️ Detect And Clean Messy Data In Transit

If you deal with messy data, check out [Qluster](https://qluster.ai/solution), another tool by the creator of DeepDiff.

*Qluster's mission is to enable users to create adaptive data pipelines that detect issues, quarantine bad data, and enable the user to fix data issues via a spreadsheet UI.*


# Survey

:mega: **Please fill out our [fast 5-question survey](https://forms.gle/E6qXexcgjoKnSzjB8)** so that we can learn how & why you use DeepDiff, and what improvements we should make. Thank you! :dancers:

# Data Cleaning




# Contribute

Expand Down
2 changes: 2 additions & 0 deletions docs/authors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Authors in order of the timeline of their contributions:
and tomli-w for dealing with tomli files.
- `Alex Sauer-Budge <https://github.com/amsb>`__ for the bugfix for
``datetime.date``.
- `William Jamieson <https://github.com/WilliamJamieson>`__ for `NumPy 2.0
compatibility <https://github.com/seperman/deepdiff/pull/422>`__

.. _Sep Dehpour (Seperman): http://www.zepworks.com
.. _Victor Hahn Castell: http://hahncastell.de
Expand Down
10 changes: 9 additions & 1 deletion docs/delta.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ Delta Serializer

DeepDiff uses pickle to serialize delta objects by default. Please take a look at the :ref:`delta_deserializer_label` for more information.


.. _to_flat_dicts:

Delta Serialize To Flat Dictionaries
------------------------------------

Read about :ref:`delta_to_flat_dicts_label`

.. _delta_dump_safety_label:

Delta Dump Safety
Expand Down Expand Up @@ -472,7 +480,7 @@ Unable to get the item at root['x']['y'][3]: 'x'
Unable to get the item at root['q']['t']
{}

# Once we set the force to be True
Once we set the force to be True

>>> delta = Delta(diff, force=True)
>>> {} + delta
Expand Down
6 changes: 6 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ The DeepDiff library includes the following modules:
What Is New
***********

DeepDiff 6-6-0
--------------

- :ref:`delta_to_flat_dicts_label` can be used to serialize delta objects into a flat list of dictionaries.
- `NumPy 2.0 compatibility <https://github.com/seperman/deepdiff/pull/422>`__ by `William Jamieson <https://github.com/WilliamJamieson>`__

DeepDiff 6-5-0
--------------

Expand Down
44 changes: 44 additions & 0 deletions docs/serialization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,48 @@ From Json Pickle
Load the diff object from the json pickle dump.
Take a look at the above :ref:`to_json_pickle_label` for an example.


.. _delta_to_flat_dicts_label:

Delta Serialize To Flat Dictionaries
------------------------------------

Sometimes, it is desired to serialize a :ref:`delta_label` object to a list of flat dictionaries. For example, to store them in relation databases. In that case, you can use the Delta.to_flat_dicts to achieve the desired outcome.

For example:

>>> from pprint import pprint
>>> from deepdiff import DeepDiff, Delta
>>> t1 = {"key1": "value1"}
>>> t2 = {"field2": {"key2": "value2"}}
>>> diff = DeepDiff(t1, t2, verbose_level=2)
>>> pprint(diff, indent=2)
{ 'dictionary_item_added': {"root['field2']": {'key2': 'value2'}},
'dictionary_item_removed': {"root['key1']": 'value1'}}
>>>
>>> delta = Delta(diff, verify_symmetry=True)
>>> flat_dicts = delta.to_flat_dicts()
>>> pprint(flat_dicts, indent=2)
[ { 'action': 'dictionary_item_added',
'path': ['field2', 'key2'],
'value': 'value2'},
{'action': 'dictionary_item_removed', 'path': ['key1'], 'value': 'value1'}]


Example 2:

>>> t3 = ["A", "B"]
>>> t4 = ["A", "B", "C", "D"]
>>> diff = DeepDiff(t3, t4, verbose_level=2)
>>> pprint(diff, indent=2)
{'iterable_item_added': {'root[2]': 'C', 'root[3]': 'D'}}
>>>
>>> delta = Delta(diff, verify_symmetry=True)
>>> flat_dicts = delta.to_flat_dicts()
>>> pprint(flat_dicts, indent=2)
[ {'action': 'iterable_item_added', 'path': [2], 'value': 'C'},
{'action': 'iterable_item_added', 'path': [3], 'value': 'D'}]



Back to :doc:`/index`

0 comments on commit 96badc7

Please sign in to comment.