Skip to content

Commit a668791

Browse files
authored
Merge pull request #143 from seperman/dev
found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround.
2 parents fa3b373 + 6f414fe commit a668791

File tree

8 files changed

+22
-14
lines changed

8 files changed

+22
-14
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DeepDiff v 4.0.5
1+
# DeepDiff v 4.0.6
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,8 @@ And then running
417417

418418
# ChangeLog
419419

420+
421+
- v4-0-6: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround.
420422
- v4-0-5: Fixing number diffing. Adding number_format_notation and number_to_string_func.
421423
- v4-0-4: Adding ignore_string_case and ignore_type_subclasses
422424
- v4-0-3: Adding versionbump tool for release

deepdiff/__init__.py

+1-1
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.5'
3+
__version__ = '4.0.6'
44
import logging
55

66
if __name__ == '__main__':

deepdiff/helper.py

+3
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,7 @@ def number_to_string(number, significant_digits, number_format_notation="f"):
241241
# Special case for 0: "-0.00" should compare equal to "0.00"
242242
if set(result) <= ZERO_DECIMAL_CHARACTERS:
243243
result = "0.00"
244+
# https://bugs.python.org/issue36622
245+
if number_format_notation == 'e' and isinstance(number, float):
246+
result = result.replace('+0', '+')
244247
return result

docs/conf.py

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

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

docs/index.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
contain the root `toctree` directive.
55
66
7-
DeepDiff 4.0.5 documentation!
7+
DeepDiff 4.0.6 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-6: found a tiny bug in Python formatting of numbers in scientific notation. Added a workaround.
284285
- v4-0-5: Fixing number diffing. Adding number_format_notation and number_to_string_func.
285286
- v4-0-4: Adding ignore_string_case and ignore_type_subclasses
286287
- v4-0-3: Adding versionbump tool for release

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 4.0.5
2+
current_version = 4.0.6
33
commit = True
44
tag = True
55
tag_name = {new_version}

setup.py

+1-1
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.5'
13+
version = '4.0.6'
1414

1515

1616
def get_reqs(filename):

tests/test_diff_text.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -1313,14 +1313,16 @@ def test_int_to_unicode(self):
13131313
}
13141314
assert result == ddiff
13151315

1316-
@pytest.mark.parametrize("t1, t2, significant_digits, number_format_notation, result", [
1317-
(Decimal('2.5'), Decimal('1.5'), 0, "f", {}),
1318-
(Decimal('2.5'), Decimal('1.5'), 1, "f", {'values_changed': {'root': {'new_value': Decimal('1.5'), 'old_value': Decimal('2.5')}}}),
1319-
(Decimal('2.5'), Decimal(2.5), 3, "f", {}),
1320-
(1024, 1022, 2, "e", {}),
1316+
@pytest.mark.parametrize("t1, t2, ignore_numeric_type_changes, significant_digits, number_format_notation, result", [
1317+
(Decimal('2.5'), Decimal('1.5'), False, 0, "f", {}),
1318+
(Decimal('2.5'), Decimal('1.5'), False, 1, "f", {'values_changed': {'root': {'new_value': Decimal('1.5'), 'old_value': Decimal('2.5')}}}),
1319+
(Decimal('2.5'), Decimal(2.5), False, 3, "f", {}),
1320+
(1024, 1022, False, 2, "e", {}),
1321+
({"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')}}})
13211322
])
1322-
def test_significant_digits_and_notation(self, t1, t2, significant_digits, number_format_notation, result):
1323-
ddiff = DeepDiff(t1, t2, significant_digits=significant_digits, number_format_notation=number_format_notation)
1323+
def test_significant_digits_and_notation(self, t1, t2, ignore_numeric_type_changes, significant_digits, number_format_notation, result):
1324+
ddiff = DeepDiff(t1, t2, significant_digits=significant_digits, number_format_notation=number_format_notation,
1325+
ignore_numeric_type_changes=ignore_numeric_type_changes)
13241326
assert result == ddiff
13251327

13261328
def test_significant_digits_for_complex_imaginary_part(self):

0 commit comments

Comments
 (0)