本文整理汇总了Python中landlab.field.graph_field.GraphFields.add_field方法的典型用法代码示例。如果您正苦于以下问题:Python GraphFields.add_field方法的具体用法?Python GraphFields.add_field怎么用?Python GraphFields.add_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类landlab.field.graph_field.GraphFields
的用法示例。
在下文中一共展示了GraphFields.add_field方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nd_field
# 需要导入模块: from landlab.field.graph_field import GraphFields [as 别名]
# 或者: from landlab.field.graph_field.GraphFields import add_field [as 别名]
def test_nd_field():
"""Test creating fields that are nd in shape."""
fields = ModelDataFields()
fields.new_field_location('node', 12)
fields.add_field('new_value', np.ones((12,4,5)), at='node')
fields.add_field('newer_value', np.ones((12,4)), at='node')
assert_raises(ValueError, fields.add_field, 'newest_value', np.ones((13,4,5)), at='node')
assert_raises(ValueError, fields.add_field, 'newestest_value', np.ones((13)), at='node')
示例2: test_nd_field
# 需要导入模块: from landlab.field.graph_field import GraphFields [as 别名]
# 或者: from landlab.field.graph_field.GraphFields import add_field [as 别名]
def test_nd_field():
"""Test creating fields that are nd in shape."""
fields = ModelDataFields()
fields.new_field_location("node", 12)
fields.add_field("new_value", np.ones((12, 4, 5)), at="node")
fields.add_field("newer_value", np.ones((12, 4)), at="node")
with pytest.raises(ValueError):
fields.add_field("newest_value", np.ones((13, 4, 5)), at="node")
with pytest.raises(ValueError):
fields.add_field("newestest_value", np.ones((13)), at="node")