def test_get_embedding_map_norm(): expected = ({ 'hakuna': np.linspace(0.1 / (0.55)**0.5, 0.5 / (0.55)**0.5, 5), 'matata': np.linspace(0.5 / (0.55)**0.5, 0.1 / (0.55)**0.5, 5) }, 5) seq = [["hakuna", "matata"], ["matata", "hakuna"]] output_ = get_embedding_map(EMBED_PATH, seq, norm=True) assert str(expected) == str(output_)
def test_get_embedding_map_freq(): expected = ({ 'hakuna': np.array([0.00013316, 0.00026631, 0.00039947, 0.00053262, 0.00066578]), 'matata': np.array([0.00199203, 0.00159363, 0.00119522, 0.00079681, 0.00039841]) }, 5) seq = [["hakuna", "matata"], ["matata", "hakuna"]] output_ = get_embedding_map(EMBED_PATH, seq, path_to_counts=FREQ_PATH) assert str(expected) == str(output_)
def test_get_embedding_map_OOV(): expected = ({}, 5) seq = [["problem-free", "philosophy"]] output_ = get_embedding_map(EMBED_PATH, seq) assert str(expected) == str(output_)
def test_get_embedding_map_wrong_dim(): seq = [["hakuna", "matata"], ["matata", "hakuna"]] with pytest.raises(AssertionError): get_embedding_map("tests/fixtures/test_embed_wrong_dim.txt", seq)