GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Do not apply format to non numbers · benthomasson/deepdiff@71a54e3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • deepdiff
    • helper.py
  • tests
    • test_diff_other.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎deepdiff/helper.py‎

Copy file name to clipboardExpand all lines: deepdiff/helper.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ def number_to_string(number, significant_digits, number_format_notation="f"):
340340
with localcontext() as ctx:
341341
ctx.prec = len(tup.digits) + tup.exponent + significant_digits
342342
number = number.quantize(Decimal('0.' + '0' * significant_digits))
343+
elif not isinstance(number, numbers):
344+
return number
343345
result = (using % significant_digits).format(number)
344346
# Special case for 0: "-0.00" should compare equal to "0.00"
345347
if set(result) <= ZERO_DECIMAL_CHARACTERS:
Collapse file

‎tests/test_diff_other.py‎

Copy file name to clipboardExpand all lines: tests/test_diff_other.py
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,15 @@ def test_path_cache(self):
8080
path1 = diff['values_changed'][0].path()
8181
path2 = diff['values_changed'][0].path()
8282
assert 'root[0]' == path1 == path2
83+
84+
def test_bool_str(self):
85+
t1 = {'key1': True}
86+
t2 = {'key1': 'Yes'}
87+
diff = DeepDiff(t1, t2, ignore_type_in_groups=[(bool, str)],
88+
ignore_numeric_type_changes=True)
89+
expected = {'values_changed':
90+
{"root['key1']":
91+
{'new_value': 'Yes', 'old_value': True}
92+
}
93+
}
94+
assert diff == expected

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.