8000 Add a test for numeric precision (see #9354) by kno10 · Pull Request #12128 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Add a test for numeric precision (see #9354) #12128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions sklearn/metrics/tests/test_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,3 +874,15 @@ def test_check_preserve_type():
59FB XB.astype(np.float))
assert_equal(XA_checked.dtype, np.float)
assert_equal(XB_checked.dtype, np.float)

def test_euclidean_precision32():
"""dot(x,x) - 2 dot(x,y) + dot(y,y) has catastrophic precision"""
XA = np.array([[10000]], np.float32)
XB = np.array([[10001]], np.float32)
assert_equal(euclidean_distances(XA, XB)[0,0], 1)

def test_euclidean_precision64():
"""dot(x,x) - 2 dot(x,y) + dot(y,y) has catastrophic precision"""
XA = np.array([[100000000]])
XB = np.array([[100000001]])
assert_equal(euclidean_distances(XA, XB)[0,0], 1)
0