Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fb7ba29

Browse filesBrowse files
committed
test(scalar): add tests for cast/rounding 32 to 64 bits
fix #10645
1 parent a085366 commit fb7ba29
Copy full SHA for fb7ba29

File tree

1 file changed

+12
-0
lines changed
Filter options

1 file changed

+12
-0
lines changed

‎numpy/core/tests/test_scalarprint.py

Copy file name to clipboardExpand all lines: numpy/core/tests/test_scalarprint.py
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ def check(v):
4848
check(1e15)
4949
check(1e16)
5050

51+
def test_scalar_cast32to64(self):
52+
# test that both str, repr and format are the same for np.float32
53+
# even though the values are cut off when casted to 64 bits (Python float)
54+
def check(v):
55+
assert_equal(str(np.float32(v)), str(v))
56+
assert_equal(format(np.float32(v)), str(v))
57+
assert_equal(repr(np.float32(v)), str(v))
58+
59+
check(101.1)
60+
check(1.01)
61+
check(1.3)
62+
5163
def test_py2_float_print(self):
5264
# gh-10753
5365
# In python2, the python float type implements an obsolete method

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.