當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。