You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/basics.rst
+44
Original file line number
Diff line number
Diff line change
@@ -143,5 +143,49 @@ Object attribute added:
143
143
You just need to set view='tree' to get it in tree form.
144
144
145
145
146
+
.. _group_by_label:
147
+
148
+
Group By
149
+
--------
150
+
151
+
group_by can be used when dealing with list of dictionaries to convert them to group them by value defined in group_by. The common use case is when reading data from a flat CSV and primary key is one of the columns in the CSV. We want to use the primary key to group the rows instead of CSV row number.
:ref:`get_deep_distance_label` will get you the deep distance between objects. The distance is a number between 0 and 1 where zero means there is no diff between the 2 objects and 1 means they are very different. Note that this number should only be used to compare the similarity of 2 objects and nothing more. The algorithm for calculating this number may or may not change in the future releases of DeepDiff.
54
54
55
55
group_by: String, default=None
56
-
:ref:`group_by` can be used when dealing with list of dictionaries to convert them to group them by value defined in group_by. The common use case is when reading data from a flat CSV and primary key is one of the columns in the CSV. We want to use the primary key to group the rows instead of CSV row number.
56
+
:ref:`group_by_label` can be used when dealing with list of dictionaries to convert them to group them by value defined in group_by. The common use case is when reading data from a flat CSV and primary key is one of the columns in the CSV. We want to use the primary key to group the rows instead of CSV row number.
57
57
58
58
hasher: default = DeepHash.murmur3_128bit
59
59
Hash function to be used. If you don't want Murmur3, you can use Python's built-in hash function
:ref:`max_diffs_label` defined the maximum number of diffs to run on objects to pin point what exactly is different. This is only used when ignore_order=True
107
107
108
+
math_epsilon: Decimal, default = None
109
+
:ref:`math_epsilon_label` uses Python's built in Math.isclose. It defines a tolerance value which is passed to math.isclose(). Any numbers that are within the tolerance will not report as being different. Any numbers outside of that tolerance will show up as different.
110
+
108
111
number_format_notation : string, default="f"
109
112
:ref:`number_format_notation_label` is what defines the meaning of significant digits. The default value of "f" means the digits AFTER the decimal point. "f" stands for fixed point. The other option is "e" which stands for exponent notation or scientific notation.
math_epsilon uses Python's built in Math.isclose. It defines a tolerance value which is passed to math.isclose(). Any numbers that are within the tolerance will not report as being different. Any numbers outside of that tolerance will show up as different.
129
+
130
+
For example for some sensor data derived and computed values must lie in a certain range. It does not matter that they are off by e.g. 1e-5.
131
+
132
+
To check against that the math core module provides the valuable isclose() function. It evaluates the being close of two numbers to each other, with reference to an epsilon (abs_tol). This is superior to the format function, as it evaluates the mathematical representation and not the string representation.
133
+
134
+
Example:
135
+
>>> from decimal import Decimal
136
+
>>> d1 = {"a": Decimal("7.175")}
137
+
>>> d2 = {"a": Decimal("7.174")}
138
+
>>> DeepDiff(d1, d2, math_epsilon=0.01)
139
+
{}
140
+
141
+
.. note::
142
+
math_epsilon cannot currently handle the hashing of values, which is done when :ref:`ignore_order_label` is True.
0 commit comments