From 111d4b9d7e95a17f4ceece85a470a787eb1ec628 Mon Sep 17 00:00:00 2001 From: Sep Dehpour Date: Fri, 12 Apr 2019 17:52:24 -0700 Subject: [PATCH 1/3] bug in scientific notation formatting --- README.md | 1 + deepdiff/helper.py | 3 +++ docs/index.rst | 1 + tests/test_diff_text.py | 16 +++++++++------- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 75e18ac1..88ef2905 100644 --- a/README.md +++ b/README.md @@ -417,6 +417,7 @@ And then running # ChangeLog +- v4-0-5: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround. - v4-0-4: Adding ignore_string_case and ignore_type_subclasses - v4-0-3: Adding versionbump tool for release - v4-0-2: Fixing installation issue where rst files are missing. diff --git a/deepdiff/helper.py b/deepdiff/helper.py index fdbb2d09..26e64cde 100644 --- a/deepdiff/helper.py +++ b/deepdiff/helper.py @@ -241,4 +241,7 @@ def number_to_string(number, significant_digits, number_format_notation="f"): # Special case for 0: "-0.00" should compare equal to "0.00" if set(result) <= ZERO_DECIMAL_CHARACTERS: result = "0.00" + # https://bugs.python.org/issue36622 + if number_format_notation == 'e' and isinstance(number, float): + result = result.replace('+0', '+') return result diff --git a/docs/index.rst b/docs/index.rst index 02a7c92d..8b7132b0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -281,6 +281,7 @@ Indices and tables Changelog ========= +- v4-0-5: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround. - v4-0-4: Adding ignore_string_case and ignore_type_subclasses - v4-0-3: Adding versionbump tool for release - v4-0-2: Fixing installation issue where rst files are missing. diff --git a/tests/test_diff_text.py b/tests/test_diff_text.py index 9028389f..06e7acc2 100755 --- a/tests/test_diff_text.py +++ b/tests/test_diff_text.py @@ -1313,14 +1313,16 @@ def test_int_to_unicode(self): } assert result == ddiff - @pytest.mark.parametrize("t1, t2, significant_digits, number_format_notation, result", [ - (Decimal('2.5'), Decimal('1.5'), 0, "f", {}), - (Decimal('2.5'), Decimal('1.5'), 1, "f", {'values_changed': {'root': {'new_value': Decimal('1.5'), 'old_value': Decimal('2.5')}}}), - (Decimal('2.5'), Decimal(2.5), 3, "f", {}), - (1024, 1022, 2, "e", {}), + @pytest.mark.parametrize("t1, t2, ignore_numeric_type_changes, significant_digits, number_format_notation, result", [ + (Decimal('2.5'), Decimal('1.5'), False, 0, "f", {}), + (Decimal('2.5'), Decimal('1.5'), False, 1, "f", {'values_changed': {'root': {'new_value': Decimal('1.5'), 'old_value': Decimal('2.5')}}}), + (Decimal('2.5'), Decimal(2.5), False, 3, "f", {}), + (1024, 1022, False, 2, "e", {}), + ({"key": [Decimal('2.0001'), Decimal('20000.0001')]}, {"key": [2.0002, 20000.0002]}, True, 4, "e", {'values_changed': {"root['key'][0]": {'new_value': 2.0002, 'old_value': Decimal('2.0001')}}}) ]) - def test_significant_digits_and_notation(self, t1, t2, significant_digits, number_format_notation, result): - ddiff = DeepDiff(t1, t2, significant_digits=significant_digits, number_format_notation=number_format_notation) + def test_significant_digits_and_notation(self, t1, t2, ignore_numeric_type_changes, significant_digits, number_format_notation, result): + ddiff = DeepDiff(t1, t2, significant_digits=significant_digits, number_format_notation=number_format_notation, + ignore_numeric_type_changes=ignore_numeric_type_changes) assert result == ddiff def test_significant_digits_for_complex_imaginary_part(self): From d46513aebf1a0f98878a0332d21f7067c2ecf07c Mon Sep 17 00:00:00 2001 From: Sep Dehpour Date: Fri, 12 Apr 2019 17:53:08 -0700 Subject: [PATCH 2/3] =?UTF-8?q?Bump=20version:=204.0.5=20=E2=86=92=204.0.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- deepdiff/__init__.py | 2 +- docs/conf.py | 4 ++-- docs/index.rst | 2 +- setup.cfg | 2 +- setup.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 88ef2905..7a04d117 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DeepDiff v 4.0.5 +# DeepDiff v 4.0.6 ![Python Versions](https://img.shields.io/pypi/pyversions/deepdiff.svg?style=flat) diff --git a/deepdiff/__init__.py b/deepdiff/__init__.py index 99a72d72..03707b99 100644 --- a/deepdiff/__init__.py +++ b/deepdiff/__init__.py @@ -1,6 +1,6 @@ """This module offers the DeepDiff, DeepSearch, grep and DeepHash classes.""" # flake8: noqa -__version__ = '4.0.5' +__version__ = '4.0.6' import logging if __name__ == '__main__': diff --git a/docs/conf.py b/docs/conf.py index 89db289e..3639e8af 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,9 +60,9 @@ # built documents. # # The short X.Y version. -version = '4.0.5' +version = '4.0.6' # The full version, including alpha/beta/rc tags. -release = '4.0.5' +release = '4.0.6' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/index.rst b/docs/index.rst index 8b7132b0..6b54f2da 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -4,7 +4,7 @@ contain the root `toctree` directive. -DeepDiff 4.0.5 documentation! +DeepDiff 4.0.6 documentation! ============================= **DeepDiff: Deep Difference of dictionaries, iterables, strings and other objects. It will recursively look for all the changes.** diff --git a/setup.cfg b/setup.cfg index 1b39b971..08269c06 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 4.0.5 +current_version = 4.0.6 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index ecabde8d..b3ed8079 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ if os.environ.get('USER', '') == 'vagrant': del os.link -version = '4.0.5' +version = '4.0.6' def get_reqs(filename): From 7173d58d22c546de87ce448982cae1e575e6d897 Mon Sep 17 00:00:00 2001 From: Sep Dehpour Date: Fri, 12 Apr 2019 17:55:44 -0700 Subject: [PATCH 3/3] fixing readme --- README.md | 3 ++- docs/index.rst | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7a04d117..02fdca59 100644 --- a/README.md +++ b/README.md @@ -417,7 +417,8 @@ And then running # ChangeLog -- v4-0-5: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround. +- v4-0-6: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround. +- v4-0-5: Fixing number diffing. Adding number_format_notation and number_to_string_func. - v4-0-4: Adding ignore_string_case and ignore_type_subclasses - v4-0-3: Adding versionbump tool for release - v4-0-2: Fixing installation issue where rst files are missing. diff --git a/docs/index.rst b/docs/index.rst index 6b54f2da..e30ba080 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -281,7 +281,8 @@ Indices and tables Changelog ========= -- v4-0-5: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround. +- v4-0-6: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround. +- v4-0-5: Fixing number diffing. Adding number_format_notation and number_to_string_func. - v4-0-4: Adding ignore_string_case and ignore_type_subclasses - v4-0-3: Adding versionbump tool for release - v4-0-2: Fixing installation issue where rst files are missing.