diff --git a/README.md b/README.md index 2de4d759..796d4835 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) @@ -417,6 +417,8 @@ And then running # ChangeLog + +- 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 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/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/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 0b0c325b..e30ba080 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.** @@ -281,6 +281,7 @@ Indices and tables Changelog ========= +- 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 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): 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):