예제 #1
0
def test_string_array():
    from pybind11_tests import create_string_array, print_string_array

    arr = create_string_array(True)
    assert str(arr.dtype) == "[('a', 'S3'), ('b', 'S3')]"
    assert print_string_array(arr) == [
        "a='',b=''", "a='a',b='a'", "a='ab',b='ab'", "a='abc',b='abc'"
    ]
    dtype = arr.dtype
    assert arr['a'].tolist() == [b'', b'a', b'ab', b'abc']
    assert arr['b'].tolist() == [b'', b'a', b'ab', b'abc']
    arr = create_string_array(False)
    assert dtype == arr.dtype
예제 #2
0
def test_string_array():
    from pybind11_tests import create_string_array, print_string_array

    arr = create_string_array(True)
    assert str(arr.dtype) == "[('a', 'S3'), ('b', 'S3')]"
    assert print_string_array(arr) == [
        "a='',b=''",
        "a='a',b='a'",
        "a='ab',b='ab'",
        "a='abc',b='abc'"
    ]
    dtype = arr.dtype
    assert arr['a'].tolist() == [b'', b'a', b'ab', b'abc']
    assert arr['b'].tolist() == [b'', b'a', b'ab', b'abc']
    arr = create_string_array(False)
    assert dtype == arr.dtype
예제 #3
0
def test_string_array():
    from pybind11_tests import create_string_array, print_string_array

    arr = create_string_array(True)
    if str(arr.dtype) != "[('a', 'S3'), ('b', 'S3')]":
        raise AssertionError
    if print_string_array(arr) != [
            "a='',b=''", "a='a',b='a'", "a='ab',b='ab'", "a='abc',b='abc'"
    ]:
        raise AssertionError
    dtype = arr.dtype
    if arr['a'].tolist() != [b'', b'a', b'ab', b'abc']:
        raise AssertionError
    if arr['b'].tolist() != [b'', b'a', b'ab', b'abc']:
        raise AssertionError
    arr = create_string_array(False)
    if dtype != arr.dtype:
        raise AssertionError