本文整理汇总了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
示例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
示例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]
示例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]
示例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)
示例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)