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"
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)
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"])
def test_str2type_simple(): assert str2type("int") == int assert str2type("float") == float assert str2type("uint32") == np.uint32
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"])'