• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.get_type_by_name函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.get_type_by_name函数的典型用法代码示例。如果您正苦于以下问题:Python get_type_by_name函数的具体用法?Python get_type_by_name怎么用?Python get_type_by_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_type_by_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_constraint_forAll2

 def test_constraint_forAll2(self):
     # !x.(P=>Q)
     # Build AST:
     string_to_file("#PREDICATE f={(1,7),(2,8),(3,9)} & S={1,2,3} & !(x,y).(y:INTEGER &(x:S & f(x)<y) & y<42 =>y:T)", file_name)
     ast_string = file_to_AST_str(file_name)
     root = str_ast_to_python_ast(ast_string)
     
     # Test
     env = Environment()
     lst = [("S", PowerSetType(IntegerType())),("f", PowerSetType(CartType(PowerSetType(IntegerType()), PowerSetType(IntegerType()))))]
     type_with_known_types(root, env, lst, ["T"])
     assert isinstance(get_type_by_name(env, "x"), IntegerType)
     assert isinstance(get_type_by_name(env, "y"), IntegerType)
     assert isinstance(get_type_by_name(env, "T"), PowerSetType)
     assert isinstance(get_type_by_name(env, "T").data, IntegerType)
     env.add_ids_to_frame(["f","S","T"])
     env.set_value("f", frozenset([(1,7),(2,8),(3,9)]))
     env.set_value("S", frozenset([1,2,3]))
     env.set_value("T", frozenset(range(10,42)))
     env._min_int = -2**8
     env._max_int = 2**8
     unqantPred = root.children[0].children[1]
     assert isinstance(unqantPred, AForallPredicate)
     varList = unqantPred.children[0:-1]
     P = unqantPred.children[-1].children[0]
     Q = unqantPred.children[-1].children[1]
     domain = compute_using_external_solver(P, env, varList)
     assert frozenset([x["x"] for x in domain])==frozenset([1,2,3])
     domain = compute_using_external_solver(P, env, varList)
     assert frozenset([x["y"] for x in domain])==frozenset(range(8,42))
开发者ID:hhu-stups,项目名称:pyB,代码行数:30,代码来源:test_constraintsolver.py


示例2: test_library_length

    def test_library_length(self):
        string = '''
        MACHINE LibraryStrings
        CONSTANTS length
        PROPERTIES
          /* compute the length of a string */
          length: STRING --> INTEGER &
          length = %x.(x:STRING|STRING_LENGTH(x)) 
        DEFINITIONS
          STRING_LENGTH(x) == length(x);
          EXTERNAL_FUNCTION_STRING_LENGTH == STRING --> INTEGER;
        ASSERTIONS
          length("abc") = 3;
          length("") = 0;
          length("hello") = 5
        END
        '''
        # Build AST
        string_to_file(string, file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Test
        env = Environment()
        dh = DefinitionHandler(env, str_ast_to_python_ast)                                   
        dh.repl_defs(root)
        mch = parse_ast(root, env)
        type_check_bmch(root, env, mch)
        assert isinstance(get_type_by_name(env, "length"), PowerSetType)
        assert isinstance(get_type_by_name(env, "length").data, CartType)
        assert isinstance(get_type_by_name(env, "length").data.left.data, StringType)
        assert isinstance(get_type_by_name(env, "length").data.right.data, IntegerType)
        arbitrary_init_machine(root, env, mch) # init VARIABLES and eval INVARIANT
        assert isinstance(root.children[4], AAssertionsMachineClause)
        interpret(root.children[4], env)
开发者ID:hhu-stups,项目名称:pyB,代码行数:35,代码来源:test_library.py


示例3: test_types_expr_leq

    def test_types_expr_leq(self):
        # Build AST
        string_to_file("#PREDICATE x<y & y=1", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        type_with_known_types(root, env, [], ["x","y"])
        assert isinstance(get_type_by_name(env, "x"), IntegerType)
        assert isinstance(get_type_by_name(env, "y"), IntegerType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:11,代码来源:test_types_numbers.py


示例4: test_types_simple_mul_unify2

    def test_types_simple_mul_unify2(self):
        # Build AST
        string_to_file("#PREDICATE 42=a*b", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        type_with_known_types(root, env, [], ["b","a"])
        assert isinstance(get_type_by_name(env, "a"), IntegerType)
        assert isinstance(get_type_by_name(env, "b"), IntegerType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:11,代码来源:test_types_numbers.py


示例5: test_types_interval2

    def test_types_interval2(self):
        # Build AST:
        string_to_file("#PREDICATE x=1..5", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        type_with_known_types(root, env, [], ["x"])
        assert isinstance(get_type_by_name(env, "x"), PowerSetType)
        assert isinstance(get_type_by_name(env, "x").data, IntegerType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:11,代码来源:test_types_numbers.py


示例6: test_types_function_app2

    def test_types_function_app2(self):
        # Build AST
        string_to_file('#PREDICATE f= {1 |-> "aa", 2 |-> "bb"}(xx) & xx=1 ', file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        type_with_known_types(root, env, [], ["xx", "f"])
        assert isinstance(get_type_by_name(env, "f"), StringType)
        assert isinstance(get_type_by_name(env, "xx"), IntegerType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:11,代码来源:test_types_functions.py


示例7: test_types_simple_set_com

    def test_types_simple_set_com(self):
        # Build AST
        string_to_file("#PREDICATE ID={x|x<10}", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        type_with_known_types(root, env, [], ["ID"])
        assert isinstance(get_type_by_name(env, "ID"), PowerSetType)
        assert isinstance(get_type_by_name(env, "x"), IntegerType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:11,代码来源:test_types_sets.py


示例8: test_types_set_power_unify2

    def test_types_set_power_unify2(self):
        # Build AST
        string_to_file("#PREDICATE 1:S ", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        type_with_known_types(root, env, [], ["S"])
        assert isinstance(get_type_by_name(env, "S"), PowerSetType)
        assert isinstance(get_type_by_name(env, "S").data, IntegerType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:11,代码来源:test_types_sets.py


示例9: type_check_sequence

    def type_check_sequence(self, ast_string):
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        lst = [("S", PowerSetType(SetType("X")))]
        type_with_known_types(root, env, lst, ["s"])
        assert isinstance(get_type_by_name(env, "s"), PowerSetType)
        assert isinstance(get_type_by_name(env, "s").data, CartType)
        assert isinstance(get_type_by_name(env, "s").data.left.data, IntegerType)
        assert isinstance(get_type_by_name(env, "s").data.right.data, SetType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:11,代码来源:test_types_functions.py


示例10: test_types_simple_pow

    def test_types_simple_pow(self):
        # Build AST
        string_to_file("#PREDICATE S=POW(B)", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        lst = [("B", PowerSetType(SetType("X")))]
        type_with_known_types(root, env, lst, ["S"])
        assert isinstance(get_type_by_name(env, "S"), PowerSetType)
        assert isinstance(get_type_by_name(env, "S").data, PowerSetType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:12,代码来源:test_types_sets.py


示例11: test_types_simple_rev

    def test_types_simple_rev(self):
        # Build AST
        string_to_file("#PREDICATE r:A<->B & f = r~ & x:dom(f)", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        lst = [("A", PowerSetType(SetType("X"))),("B", PowerSetType(SetType("Y")))]
        type_with_known_types(root, env, lst, ["r","x","f"])
        assert isinstance(get_type_by_name(env, "x"), SetType)
        assert get_type_by_name(env, "x").name =="Y"
开发者ID:hhu-stups,项目名称:pyB,代码行数:12,代码来源:test_types_relations.py


示例12: test_types_seq_last

    def test_types_seq_last(self):
        # Build AST
        string_to_file("#PREDICATE s:perm(S) & n=last(s)", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        lst = [("S", PowerSetType(SetType("X")))]
        type_with_known_types(root, env, lst, ["s", "n"])
        assert isinstance(get_type_by_name(env, "n"), SetType)
        assert get_type_by_name(env, "n").name == "X"
开发者ID:hhu-stups,项目名称:pyB,代码行数:12,代码来源:test_types_functions.py


示例13: test_types_simple_sub_res

    def test_types_simple_sub_res(self):
        # Build AST
        string_to_file("#PREDICATE r:A<->B & v=S <| r", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        lst = [("S", PowerSetType(SetType("X"))),("A", PowerSetType(SetType("X"))),("B", PowerSetType(SetType("Y")))]
        type_with_known_types(root, env, lst, ["r","v"])
        assert isinstance(get_type_by_name(env, "v"), PowerSetType)
        assert isinstance(get_type_by_name(env, "v").data, CartType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:12,代码来源:test_types_relations.py


示例14: test_types_bool

    def test_types_bool(self):
        # Build AST
        string_to_file("#PREDICATE A:BOOL & B:BOOL & C:BOOL & (A=TRUE <=> (B=FALSE or C=FALSE)) & (B=TRUE <=> A=TRUE)", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        type_with_known_types(root, env, [], ["A","B","C"])
        assert isinstance(get_type_by_name(env, "A"), BoolType)
        assert isinstance(get_type_by_name(env, "B"), BoolType)
        assert isinstance(get_type_by_name(env, "C"), BoolType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:12,代码来源:test_types_sets.py


示例15: test_types_function_app

    def test_types_function_app(self):
        # Build AST
        string_to_file("#PREDICATE f:S+->T & y=f(x)", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        lst = [("x", SetType("X")), ("S", PowerSetType(SetType("X"))), ("T", PowerSetType(SetType("Y")))]
        type_with_known_types(root, env, lst, ["y", "f"])
        assert isinstance(get_type_by_name(env, "y"), SetType)
        assert get_type_by_name(env, "y").name == "Y"
开发者ID:hhu-stups,项目名称:pyB,代码行数:12,代码来源:test_types_functions.py


示例16: test_types_range

    def test_types_range(self):
        # Build AST
        string_to_file("#PREDICATE r:S<->T & x:ran(r)", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        lst = [("S", PowerSetType(SetType("X"))),("T", PowerSetType(SetType("Y")))]
        type_with_known_types(root, env, lst, ["r","x"])
        assert isinstance(get_type_by_name(env, "x"), SetType)
        assert get_type_by_name(env, "x").name == "Y"
开发者ID:hhu-stups,项目名称:pyB,代码行数:12,代码来源:test_types_relations.py


示例17: test_types_relation_set_enum

    def test_types_relation_set_enum(self):
        # Build AST
        string_to_file("#PREDICATE r = {8|->10, 7|->11, 2|->11, 6|->12}", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        type_with_known_types(root, env, [], ["r"])
        assert isinstance(get_type_by_name(env, "r"), PowerSetType)
        assert isinstance(get_type_by_name(env, "r").data, CartType)
        assert isinstance(get_type_by_name(env, "r").data.left.data, IntegerType)
        assert isinstance(get_type_by_name(env, "r").data.right.data, IntegerType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:13,代码来源:test_types_relations.py


示例18: test_types_ran_unify

    def test_types_ran_unify(self):
        # Build AST
        string_to_file("#PREDICATE d=A*B & c=ran(d) & A=NAT & B=NAT", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        env = Environment()
        type_with_known_types(root, env, [], ["c","d","A","B"])
        assert isinstance(get_type_by_name(env, "A"), PowerSetType)
        assert isinstance(get_type_by_name(env, "B"), PowerSetType)
        assert isinstance(get_type_by_name(env, "c"), PowerSetType)
        assert isinstance(get_type_by_name(env, "d"), PowerSetType)
        assert isinstance(get_type_by_name(env, "d").data, CartType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:13,代码来源:test_types_relations.py


示例19: test_types_seq_extention

    def test_types_seq_extention(self):
        # Build AST
        string_to_file("#PREDICATE s=[1,2,3]", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        type_with_known_types(root, env, [], ["s"])
        assert isinstance(get_type_by_name(env, "s"), PowerSetType)
        assert isinstance(get_type_by_name(env, "s").data, CartType)
        assert isinstance(get_type_by_name(env, "s").data.left.data, IntegerType)
        assert isinstance(get_type_by_name(env, "s").data.right.data, IntegerType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:13,代码来源:test_types_functions.py


示例20: test_types_set_cart_unify4

    def test_types_set_cart_unify4(self):
        # Build AST
        string_to_file("#PREDICATE NAT*B=A*POW(NAT)", file_name)
        ast_string = file_to_AST_str(file_name)
        root = str_ast_to_python_ast(ast_string)

        # Type
        env = Environment()
        type_with_known_types(root, env, [], ["A","B"])
        assert isinstance(get_type_by_name(env, "A"), PowerSetType)
        assert isinstance(get_type_by_name(env, "B"), PowerSetType)
        assert isinstance(get_type_by_name(env, "A").data, IntegerType)
        assert isinstance(get_type_by_name(env, "B").data, PowerSetType)
        assert isinstance(get_type_by_name(env, "B").data.data, IntegerType)
开发者ID:hhu-stups,项目名称:pyB,代码行数:14,代码来源:test_types_sets.py



注:本文中的util.get_type_by_name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.get_uuid函数代码示例发布时间:2022-05-27
下一篇:
Python util.get_stdout函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap