Skip to content

Commit 974c5f3

Browse files
authored
Merge pull request #162 from seperman/dev
Dev
2 parents 354cf7f + 22072f9 commit 974c5f3

File tree

11 files changed

+45
-10
lines changed

11 files changed

+45
-10
lines changed

MANIFEST.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
include LICENSE
2+
include AUTHORS
13
include *.rst
24
include deepdiff/*.rst
35
include *.txt
4-
include LICENSE AUTHORS
6+
include *.sh
7+
include pytest.ini
8+
include *.py
59
recursive-include tests *.py
610
global-exclude __pycache__
711
global-exclude *.py[co]

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DeepDiff v 4.0.7
1+
# DeepDiff v 4.0.8
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)
@@ -417,6 +417,7 @@ And then running
417417

418418
# ChangeLog
419419

420+
- v4-0-8: Adding ignore_nan_inequality for float('nan')
420421
- v4-0-7: Hashing of the number 1 vs. True
421422
- v4-0-6: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround.
422423
- v4-0-5: Fixing number diffing. Adding number_format_notation and number_to_string_func.

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 and DeepHash classes."""
22
# flake8: noqa
3-
__version__ = '4.0.7'
3+
__version__ = '4.0.8'
44
import logging
55

66
if __name__ == '__main__':

deepdiff/diff.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(self,
5959
ignore_type_subclasses=False,
6060
ignore_string_case=False,
6161
number_to_string_func=None,
62+
ignore_nan_inequality=False,
6263
verbose_level=1,
6364
view=TEXT_VIEW,
6465
hasher=None,
@@ -69,7 +70,7 @@ def __init__(self,
6970
"The valid parameters are ignore_order, report_repetition, significant_digits, "
7071
"number_format_notation, exclude_paths, exclude_types, exclude_regex_paths, ignore_type_in_groups, "
7172
"ignore_string_type_changes, ignore_numeric_type_changes, ignore_type_subclasses, "
72-
"number_to_string_func, verbose_level, view, and hasher.") % ', '.join(kwargs.keys()))
73+
"ignore_nan_inequality, number_to_string_func, verbose_level, view, and hasher.") % ', '.join(kwargs.keys()))
7374

7475
self.ignore_order = ignore_order
7576
self.ignore_type_in_groups = self.get_ignore_types_in_groups(
@@ -88,6 +89,7 @@ def __init__(self,
8889
self.type_check_func = type_is_subclass_of_type_group if ignore_type_subclasses else type_in_type_group
8990
self.ignore_string_case = ignore_string_case
9091
self.number_to_string = number_to_string_func or number_to_string
92+
self.ignore_nan_inequality = ignore_nan_inequality
9193
self.hashes = {}
9294
self.hasher = hasher
9395

@@ -613,6 +615,9 @@ def __diff(self, level, parents_ids=frozenset({})):
613615
self.__diff_types(level)
614616
return
615617

618+
if self.ignore_nan_inequality and isinstance(level.t1, float) and str(level.t1) == str(level.t2) == 'nan':
619+
return
620+
616621
if isinstance(level.t1, strings):
617622
self.__diff_str(level)
618623

deepdiff/diff_doc.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ ignore_type_subclasses: Boolean, default = False
8686
ignore_string_case: Boolean, default = False
8787
Whether to be case-sensitive or not when comparing strings. By settings ignore_string_case=False, strings will be compared case-insensitively.
8888

89+
ignore_nan_inequality: Boolean, default = False
90+
Whether to ignore float('nan') inequality in Python.
91+
92+
8993
**Returns**
9094

9195
A DeepDiff object that has already calculated the difference of the 2 items.
@@ -473,6 +477,7 @@ ignore_type_subclasses
473477
>>> DeepDiff(obj_a, obj_c, ignore_type_in_groups=[(ClassA, ClassB)], ignore_type_subclasses=True)
474478
{'values_changed': {'root.x': {'new_value': 3, 'old_value': 1}}, 'attribute_removed': [root.y]}
475479

480+
476481
ignore_string_case
477482
Whether to be case-sensitive or not when comparing strings. By settings ignore_string_case=False, strings will be compared case-insensitively.
478483

@@ -482,6 +487,15 @@ ignore_string_case
482487
{}
483488

484489

490+
ignore_nan_inequality
491+
Whether to ignore float('nan') inequality in Python. Note that this is a cPython "feature". Some versions of Pypy3 for example have nan==nan.
492+
493+
>>> float('nan') == float('nan')
494+
False
495+
>>> DeepDiff(float('nan'), float('nan'))
496+
{'values_changed': {'root': {'new_value': nan, 'old_value': nan}}}
497+
>>> DeepDiff(float('nan'), float('nan'), ignore_nan_inequality=True)
498+
{}
485499

486500
**Tree View**
487501

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 = '4.0.7'
63+
version = '4.0.8'
6464
# The full version, including alpha/beta/rc tags.
65-
release = '4.0.7'
65+
release = '4.0.8'
6666

6767
# The language for content autogenerated by Sphinx. Refer to documentation
6868
# for a list of supported languages.

docs/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
contain the root `toctree` directive.
55
66
7-
DeepDiff 4.0.7 documentation!
7+
DeepDiff 4.0.8 documentation!
88
=============================
99

1010
**DeepDiff: Deep Difference of dictionaries, iterables, strings and other objects. It will recursively look for all the changes.**
@@ -281,6 +281,7 @@ Indices and tables
281281
Changelog
282282
=========
283283

284+
- v4-0-8: Adding ignore_nan_inequality for float('nan')
284285
- v4-0-7: Hashing of the number 1 vs. True
285286
- v4-0-6: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround.
286287
- v4-0-5: Fixing number diffing. Adding number_format_notation and number_to_string_func.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
jsonpickle==1.0
2-
ordered-set==3.1
2+
ordered-set==3.1.1

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 = 4.0.7
2+
current_version = 4.0.8
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 = '4.0.7'
13+
version = '4.0.8'
1414

1515

1616
def get_reqs(filename):

0 commit comments

Comments
 (0)