From defcaae4bd404aeba16d22966281c54d98ff8995 Mon Sep 17 00:00:00 2001 From: xuyige Date: Fri, 12 Jul 2019 04:39:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86test=5Fembed=5Floader=E7=9A=84almost?= =?UTF-8?q?=20equal=E8=8C=83=E5=9B=B4=E7=A8=8D=E7=A8=8D=E8=B0=83=E5=A4=A7?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=EF=BC=8C=E4=BB=A5=E9=98=B2=E6=AD=A2=E5=81=B6?= =?UTF-8?q?=E7=84=B6=E7=9A=84=E6=B5=8B=E8=AF=95=E4=B8=8D=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/io/test_embed_loader.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/io/test_embed_loader.py b/test/io/test_embed_loader.py index dfbc5205..bbfe8858 100644 --- a/test/io/test_embed_loader.py +++ b/test/io/test_embed_loader.py @@ -16,7 +16,7 @@ class TestEmbedLoader(unittest.TestCase): self.assertEqual(g_m.shape, (4, 50)) w_m = EmbedLoader.load_with_vocab(word2vec, vocab, normalize=True) self.assertEqual(w_m.shape, (4, 50)) - self.assertAlmostEqual(np.linalg.norm(w_m, axis=1).sum(), delta=1e-3) + self.assertAlmostEqual(np.linalg.norm(w_m, axis=1).sum(), 4, delta=1e-4) def test_load_without_vocab(self): words = ['the', 'of', 'in', 'a', 'to', 'and'] @@ -28,13 +28,13 @@ class TestEmbedLoader(unittest.TestCase): self.assertIn(word, vocab) w_m, vocab = EmbedLoader.load_without_vocab(word2vec, normalize=True) self.assertEqual(w_m.shape, (8, 50)) - self.assertAlmostEqual(np.linalg.norm(w_m, axis=1).sum(), delta=1e-4) + self.assertAlmostEqual(np.linalg.norm(w_m, axis=1).sum(), 8, delta=1e-4) for word in words: self.assertIn(word, vocab) # no unk w_m, vocab = EmbedLoader.load_without_vocab(word2vec, normalize=True, unknown=None) self.assertEqual(w_m.shape, (7, 50)) - self.assertAlmostEqual(np.linalg.norm(w_m, axis=1).sum(), delta=1e-4) + self.assertAlmostEqual(np.linalg.norm(w_m, axis=1).sum(), 7, delta=1e-4) for word in words: self.assertIn(word, vocab)