当前位置: 首页>>代码示例>>Python>>正文


Python types.ListType方法代码示例

本文整理汇总了Python中schematics.types.ListType方法的典型用法代码示例。如果您正苦于以下问题:Python types.ListType方法的具体用法?Python types.ListType怎么用?Python types.ListType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在schematics.types的用法示例。


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

示例1: test_autoname_lists

# 需要导入模块: from schematics import types [as 别名]
# 或者: from schematics.types import ListType [as 别名]
def test_autoname_lists():
    """Tests that autoname works with lists."""

    class Model(optplan.ProblemGraphNode):
        type = types.StringType(default="Model")
        value = types.ListType(types.ModelType(ModelB))

    modelb1 = ModelB(int_field=1)
    modelb2 = ModelB(int_field=2)
    model = Model(value=[modelb1, modelb2])

    optplan.autoname(model)

    assert model.name
    assert modelb1.name
    assert modelb2.name 
开发者ID:stanfordnqp,项目名称:spins-b,代码行数:18,代码来源:test_optplan.py

示例2: test_extract_nodes_lists

# 需要导入模块: from schematics import types [as 别名]
# 或者: from schematics.types import ListType [as 别名]
def test_extract_nodes_lists():
    """Tests that it works with lists."""

    class Model(optplan.ProblemGraphNode):
        type = types.StringType(default="Model")
        value = types.ListType(types.ModelType(ModelB))

    modelb1 = ModelB(int_field=1)
    modelb2 = ModelB(int_field=2)
    model = Model(value=[modelb1, modelb2])

    model_list = []
    io._extract_nodes(model, model_list)

    assert len(model_list) == 3
    assert model in model_list
    assert modelb1 in model_list
    assert modelb2 in model_list 
开发者ID:stanfordnqp,项目名称:spins-b,代码行数:20,代码来源:test_optplan.py

示例3: test_replace_ref_nodes_with_names_lists

# 需要导入模块: from schematics import types [as 别名]
# 或者: from schematics.types import ListType [as 别名]
def test_replace_ref_nodes_with_names_lists():
    """Tests that it works with lists."""

    class Model(optplan.ProblemGraphNodeSchema):
        type = types.StringType(default="Model")
        value = types.ListType(
            optplan.ReferenceType(optplan.ProblemGraphNodeSchema))

    modelb1 = ModelB(name="m1", int_field=1)
    modelb2 = ModelB(name="m2", int_field=2)
    model = Model(name="m3", value=[modelb1, modelb2])

    model_list = [modelb1, modelb2, model]
    schema._replace_ref_nodes_with_names(model, model_list)

    assert model.value == [modelb1.name, modelb2.name] 
开发者ID:stanfordnqp,项目名称:spins-b,代码行数:18,代码来源:test_schema.py

示例4: test_replace_ref_nodes_with_names_lists

# 需要导入模块: from schematics import types [as 别名]
# 或者: from schematics.types import ListType [as 别名]
def test_replace_ref_nodes_with_names_lists():
    """Tests that it works with lists."""

    class Model(optplan.ProblemGraphNode):
        type = types.StringType(default="Model")
        value = types.ListType(optplan.ReferenceType(optplan.ProblemGraphNode))

    modelb1 = ModelB(name="m1", int_field=1)
    modelb2 = ModelB(name="m2", int_field=2)
    model = Model(name="m3", value=[modelb1, modelb2])

    model_list = [modelb1, modelb2, model]
    io._replace_ref_nodes_with_names(model, model_list)

    assert model.value == [modelb1.name, modelb2.name] 
开发者ID:stanfordnqp,项目名称:spins-b,代码行数:17,代码来源:test_optplan.py

示例5: vec2d

# 需要导入模块: from schematics import types [as 别名]
# 或者: from schematics.types import ListType [as 别名]
def vec2d(**kwargs) -> types.ListType:
    """Returns a 2D vector type."""
    return types.ListType(types.FloatType(), min_size=2, max_size=2, **kwargs) 
开发者ID:stanfordnqp,项目名称:spins-b,代码行数:5,代码来源:optplan.py

示例6: vec3d

# 需要导入模块: from schematics import types [as 别名]
# 或者: from schematics.types import ListType [as 别名]
def vec3d(**kwargs) -> types.ListType:
    """Returns a 3D vector type."""
    return types.ListType(types.FloatType(), min_size=3, max_size=3, **kwargs) 
开发者ID:stanfordnqp,项目名称:spins-b,代码行数:5,代码来源:optplan.py


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