コード例 #1
0
def test_set():
    str2type("int set")
    S = Set["str"]
    S.get_template_parameters()
    repr(S)
    assert isinstance(S, SetMeta)
    assert S.format_as_backend_type(base_type_formatter) == "str set"
コード例 #2
0
def test_str2type_arrays():
    A1 = Array[int, "1d"]
    compare_array_types(str2type("int[]"), A1)
    compare_array_types(str2type("int[:]"), A1)

    A2 = Array[np.uint32, "2d"]
    compare_array_types(str2type("uint32[:,:]"), A2)
コード例 #3
0
def test_str2type_or():
    result = str2type("int or float")
    assert isinstance(result, UnionMeta)
    assert result.types == (int, float)

    result = str2type("int or float[]")
    assert isinstance(result, UnionMeta)
    compare_array_types(result.types[1], Array[float, "1d"])
コード例 #4
0
def test_str2type_simple():
    assert str2type("int") == int
    assert str2type("float") == float
    assert str2type("uint32") == np.uint32
コード例 #5
0
def test_const():
    A = str2type("int[]")
    B = const(A)
    assert A.format_as_backend_type(
        base_type_formatter) == B.format_as_backend_type(base_type_formatter)
    assert repr(B) == 'const(Array[int, "1d"])'