本文整理汇总了Python中landlab.field.graph_field.GraphFields.add_zeros方法的典型用法代码示例。如果您正苦于以下问题:Python GraphFields.add_zeros方法的具体用法?Python GraphFields.add_zeros怎么用?Python GraphFields.add_zeros使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类landlab.field.graph_field.GraphFields
的用法示例。
在下文中一共展示了GraphFields.add_zeros方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_field_with_clobber
# 需要导入模块: from landlab.field.graph_field import GraphFields [as 别名]
# 或者: from landlab.field.graph_field.GraphFields import add_zeros [as 别名]
def test_add_field_with_clobber():
"""Test adding a field with clobber on."""
fields = ModelDataFields()
fields.new_field_location('node', 12)
assert fields.add_empty('a', at='node') is not fields.add_empty('a', at='node', noclobber=False)
assert fields.add_ones('b', at='node') is not fields.add_ones('b', at='node', noclobber=False)
assert fields.add_zeros('c', at='node') is not fields.add_zeros('c', at='node', noclobber=False)
示例2: test_grid_field_add_zeros_ones_empty
# 需要导入模块: from landlab.field.graph_field import GraphFields [as 别名]
# 或者: from landlab.field.graph_field.GraphFields import add_zeros [as 别名]
def test_grid_field_add_zeros_ones_empty():
"""Test creating scalar fields with add_zeros, add_empty, and add_ones."""
fields = ModelDataFields()
fields.new_field_location("grid", 1)
with pytest.raises(ValueError):
fields.add_zeros("value", at="grid")
with pytest.raises(ValueError):
fields.add_empty("value", at="grid")
with pytest.raises(ValueError):
fields.add_ones("value", at="grid")
示例3: test_add_existing_field_with_noclobber
# 需要导入模块: from landlab.field.graph_field import GraphFields [as 别名]
# 或者: from landlab.field.graph_field.GraphFields import add_zeros [as 别名]
def test_add_existing_field_with_noclobber():
"""Test noclobber raises an error with an existing field."""
fields = ModelDataFields()
fields.new_field_location("node", 12)
fields.add_empty("z", at="node")
with pytest.raises(FieldError):
fields.add_empty("z", at="node", noclobber=True)
with pytest.raises(FieldError):
fields.add_ones("z", at="node", noclobber=True)
with pytest.raises(FieldError):
fields.add_zeros("z", at="node", noclobber=True)
示例4: test_add_existing_field_default
# 需要导入模块: from landlab.field.graph_field import GraphFields [as 别名]
# 或者: from landlab.field.graph_field.GraphFields import add_zeros [as 别名]
def test_add_existing_field_default():
"""Test default is to not replace existing field."""
fields = ModelDataFields()
fields.new_field_location("node", 12)
fields.add_empty("z", at="node")
with pytest.raises(FieldError):
fields.add_empty("z", at="node")
with pytest.raises(FieldError):
fields.add_ones("z", at="node")
with pytest.raises(FieldError):
fields.add_zeros("z", at="node")
示例5: test_add_field_with_noclobber
# 需要导入模块: from landlab.field.graph_field import GraphFields [as 别名]
# 或者: from landlab.field.graph_field.GraphFields import add_zeros [as 别名]
def test_add_field_with_noclobber():
"""Test noclobber does not raise an error with an new field."""
fields = ModelDataFields()
fields.new_field_location('node', 12)
fields.add_empty('a', at='node', noclobber=True)
assert_true('a' in fields['node'])
fields.add_ones('b', at='node', noclobber=True)
assert_true('b' in fields['node'])
fields.add_zeros('c', at='node', noclobber=True)
assert_true('c' in fields['node'])
示例6: test_add_field_with_noclobber
# 需要导入模块: from landlab.field.graph_field import GraphFields [as 别名]
# 或者: from landlab.field.graph_field.GraphFields import add_zeros [as 别名]
def test_add_field_with_noclobber():
"""Test noclobber does not raise an error with an new field."""
fields = ModelDataFields()
fields.new_field_location("node", 12)
fields.add_empty("a", at="node", noclobber=True)
assert "a" in fields["node"]
fields.add_ones("b", at="node", noclobber=True)
assert "b" in fields["node"]
fields.add_zeros("c", at="node", noclobber=True)
assert "c" in fields["node"]
示例7: test_delete_field
# 需要导入模块: from landlab.field.graph_field import GraphFields [as 别名]
# 或者: from landlab.field.graph_field.GraphFields import add_zeros [as 别名]
def test_delete_field():
fields = ModelDataFields()
fields.new_field_location('link', 17)
assert_dict_equal(dict(), fields.at_link)
assert_raises(AttributeError, lambda: fields.at_node)
fields.add_zeros('link', 'vals')
assert_array_equal(np.zeros(17), fields.at_link['vals'])
assert_raises(KeyError, lambda: fields.delete_field('node', 'vals'))
fields.delete_field('link', 'vals')
assert_raises(KeyError, lambda: fields.field_units('link', 'vals'))
assert_raises(KeyError, lambda: fields.at_link['vals'])
示例8: test_add_field_with_clobber
# 需要导入模块: from landlab.field.graph_field import GraphFields [as 别名]
# 或者: from landlab.field.graph_field.GraphFields import add_zeros [as 别名]
def test_add_field_with_clobber():
"""Test adding a field with clobber on."""
fields = ModelDataFields()
fields.new_field_location("node", 12)
assert fields.add_empty("a", at="node") is not fields.add_empty(
"a", at="node", noclobber=False
)
assert fields.add_ones("b", at="node") is not fields.add_ones(
"b", at="node", noclobber=False
)
assert fields.add_zeros("c", at="node") is not fields.add_zeros(
"c", at="node", noclobber=False
)
示例9: test_delete_field
# 需要导入模块: from landlab.field.graph_field import GraphFields [as 别名]
# 或者: from landlab.field.graph_field.GraphFields import add_zeros [as 别名]
def test_delete_field():
fields = ModelDataFields()
fields.new_field_location("link", 17)
assert dict() == fields.at_link
with pytest.raises(AttributeError):
fields.at_node
fields.add_zeros("link", "vals")
assert_array_equal(np.zeros(17), fields.at_link["vals"])
with pytest.raises(KeyError):
fields.delete_field("node", "vals")
fields.delete_field("link", "vals")
with pytest.raises(KeyError):
fields.field_units("link", "vals")
with pytest.raises(KeyError):
fields.at_link["vals"]