示例#1
0
def test_CharacterArrayCoder_encode(data):
    coder = strings.CharacterArrayCoder()
    raw = Variable(('x', ), data)
    actual = coder.encode(raw)
    expected = Variable(('x', 'string2'), np.array([[b'a', b''], [b'b',
                                                                  b'c']]))
    assert_identical(actual, expected)
示例#2
0
def test_CharacterArrayCoder_char_dim_name(original, expected_char_dim_name):
    coder = strings.CharacterArrayCoder()
    encoded = coder.encode(original)
    roundtripped = coder.decode(encoded)
    assert encoded.dims[-1] == expected_char_dim_name
    assert roundtripped.encoding["char_dim_name"] == expected_char_dim_name
    assert roundtripped.dims[-1] == original.dims[-1]
示例#3
0
def test_CharacterArrayCoder_encode(data):
    coder = strings.CharacterArrayCoder()
    raw = Variable(("x", ), data)
    actual = coder.encode(raw)
    expected = Variable(("x", "string2"), np.array([[b"a", b""], [b"b",
                                                                  b"c"]]))
    assert_identical(actual, expected)
示例#4
0
def test_CharacterArrayCoder_roundtrip(original):
    coder = strings.CharacterArrayCoder()
    roundtripped = coder.decode(coder.encode(original))
    assert_identical(original, roundtripped)