예제 #1
0
def test_CharacterAtomizer_deatomize():
    c = clgen.CharacterAtomizer({'a': 1, 'b': 2, 'c': 3})
    assert c.deatomize([1, 2, 3, 1, 2, 3]) == 'abcabc'

    text = """
__kernel void A(__global float* a, const int b, const double c) {
  int d = get_global_id(0);
  if (b < get_global_size(0))
    a[d] *= (float)c;
}
"""
    c = clgen.CharacterAtomizer.from_text(text)
    assert c.deatomize(c.atomize(text)) == text
예제 #2
0
def test_CharacterAtomizer_deatomize_error():
    c = clgen.CharacterAtomizer({'a': 1, 'b': 2, 'c': 3})
    with pytest.raises(clgen.VocabError):
        c.deatomize([1, 2, 5, 10, 0])
예제 #3
0
def test_CharacterAtomizer_atomize_error():
    c = clgen.CharacterAtomizer({'a': 1, 'b': 2, 'c': 3})
    with pytest.raises(clgen.VocabError):
        c.atomize('abcdeabc')
예제 #4
0
def test_CharacterAtomizer_atomize():
    c = clgen.CharacterAtomizer({'a': 1, 'b': 2, 'c': 3})
    assert list(c.atomize('abcabc')) == [1, 2, 3, 1, 2, 3]