Пример #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]