From e120561294cb5a339fc40c91219a3d1aaa26ec9a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 23 Oct 2016 19:56:16 +0200 Subject: [PATCH] Fix vector_norm test. --- spacy/tests/tokens/test_token_api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spacy/tests/tokens/test_token_api.py b/spacy/tests/tokens/test_token_api.py index 832350938..acd6332b5 100644 --- a/spacy/tests/tokens/test_token_api.py +++ b/spacy/tests/tokens/test_token_api.py @@ -5,6 +5,7 @@ from spacy.attrs import IS_SPACE, IS_TITLE, IS_UPPER, LIKE_URL, LIKE_NUM from spacy.attrs import IS_STOP import pytest +import numpy @pytest.mark.models @@ -67,7 +68,9 @@ def test_vectors(EN): assert apples.similarity(oranges) > apples.similarity(oov) assert apples.similarity(oranges) == oranges.similarity(apples) assert sum(apples.vector) != sum(oranges.vector) - assert apples.vector_norm != oranges.vector_norm + assert numpy.isclose( + apples.vector_norm, + numpy.sqrt(numpy.dot(apples.vector, apples.vector))) @pytest.mark.models def test_ancestors(EN):