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


Python graph_field.GraphFields类代码示例

本文整理汇总了Python中landlab.field.graph_field.GraphFields的典型用法代码示例。如果您正苦于以下问题:Python GraphFields类的具体用法?Python GraphFields怎么用?Python GraphFields使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_getitem

def test_getitem():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)

    assert_dict_equal(dict(), fields['node'])
    assert_raises(GroupError, lambda k: fields[k], 'cell')
    assert_raises(KeyError, lambda k: fields[k], 'cell')
开发者ID:Carralex,项目名称:landlab,代码行数:7,代码来源:test_graph_fields.py

示例2: test_grid_field_zeros_ones_empty

def test_grid_field_zeros_ones_empty():
    """Test creating scalar fields with zeros, empty, and ones."""
    fields = ModelDataFields()
    fields.new_field_location('grid', 1)    
    assert_raises(ValueError, fields.zeros, 'grid')
    assert_raises(ValueError, fields.empty, 'grid')
    assert_raises(ValueError, fields.ones, 'grid')
开发者ID:Carralex,项目名称:landlab,代码行数:7,代码来源:test_graph_fields.py

示例3: test_grid_field_add_zeros_ones_empty

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)
    
    assert_raises(ValueError, fields.add_zeros, 'value', at='grid')
    assert_raises(ValueError, fields.add_empty, 'value', at='grid')
    assert_raises(ValueError, fields.add_ones, 'value', at='grid')
开发者ID:Carralex,项目名称:landlab,代码行数:8,代码来源:test_graph_fields.py

示例4: test_getitem

def test_getitem():
    fields = ModelDataFields()
    fields.new_field_location("node", 12)

    assert dict() == fields["node"]
    with pytest.raises(GroupError):
        fields["cell"]
    with pytest.raises(KeyError):
        fields["cell"]
开发者ID:cmshobe,项目名称:landlab,代码行数:9,代码来源:test_graph_fields.py

示例5: test_at_attribute

def test_at_attribute():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)

    assert_dict_equal(dict(), fields.at_node)
    assert_raises(AttributeError, lambda: fields.at_cell)

    fields.add_ones('z', at='node')
    assert_array_equal(np.ones(12), fields.at_node['z'])
开发者ID:Carralex,项目名称:landlab,代码行数:9,代码来源:test_graph_fields.py

示例6: test_add_existing_field_with_noclobber

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')

    assert_raises(FieldError, fields.add_empty, 'z', at='node', noclobber=True)
    assert_raises(FieldError, fields.add_ones, 'z', at='node', noclobber=True)
    assert_raises(FieldError, fields.add_zeros, 'z', at='node', noclobber=True)
开发者ID:Carralex,项目名称:landlab,代码行数:9,代码来源:test_graph_fields.py

示例7: test_add_existing_field_default

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')

    assert_raises(FieldError, fields.add_empty, 'z', at='node')
    assert_raises(FieldError, fields.add_ones, 'z', at='node')
    assert_raises(FieldError, fields.add_zeros, 'z', at='node')
开发者ID:Carralex,项目名称:landlab,代码行数:9,代码来源:test_graph_fields.py

示例8: test_at_attribute

def test_at_attribute():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)

    assert dict() == fields.at_node
    with pytest.raises(AttributeError):
        fields.at_cell

    fields.add_ones('z', at='node')
    assert_array_equal(np.ones(12), fields.at_node['z'])
开发者ID:Glader011235,项目名称:Landlab,代码行数:10,代码来源:test_graph_fields.py

示例9: test_nd_field

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')
开发者ID:Carralex,项目名称:landlab,代码行数:10,代码来源:test_graph_fields.py

示例10: test_add_field_with_clobber

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)
开发者ID:Glader011235,项目名称:Landlab,代码行数:8,代码来源:test_graph_fields.py

示例11: test_grid_field_zeros_ones_empty

def test_grid_field_zeros_ones_empty():
    """Test creating scalar fields with zeros, empty, and ones."""
    fields = ModelDataFields()
    fields.new_field_location("grid", 1)
    with pytest.raises(ValueError):
        fields.zeros("grid")
    with pytest.raises(ValueError):
        fields.empty("grid")
    with pytest.raises(ValueError):
        fields.ones("grid")
开发者ID:cmshobe,项目名称:landlab,代码行数:10,代码来源:test_graph_fields.py

示例12: test_scalar_field

def test_scalar_field():
    """Test adding a generic scalar field."""
    fields = ModelDataFields()
    fields.new_field_location('all_over_the_place', 1)

    assert_dict_equal(dict(), fields.at_all_over_the_place)
    assert_raises(AttributeError, lambda: fields.at_cell)

    fields.at_all_over_the_place['const'] = 1.
    assert_array_equal(np.array(1.), fields.at_all_over_the_place['const'])
    
    val = np.array(2.)
    fields.at_all_over_the_place['const'] = val
    assert_is(val, fields.at_all_over_the_place['const'])
开发者ID:Carralex,项目名称:landlab,代码行数:14,代码来源:test_graph_fields.py

示例13: test_scalar_field

def test_scalar_field():
    """Test adding a generic scalar field."""
    fields = ModelDataFields()
    fields.new_field_location("all_over_the_place", 1)

    assert dict() == fields.at_all_over_the_place
    with pytest.raises(AttributeError):
        fields.at_cell

    fields.at_all_over_the_place["const"] = 1.
    assert_array_equal(np.array(1.), fields.at_all_over_the_place["const"])

    val = np.array(2.)
    fields.at_all_over_the_place["const"] = val
    assert val is fields.at_all_over_the_place["const"]
开发者ID:cmshobe,项目名称:landlab,代码行数:15,代码来源:test_graph_fields.py

示例14: test_add_field_with_noclobber

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'])
开发者ID:Carralex,项目名称:landlab,代码行数:13,代码来源:test_graph_fields.py

示例15: test_add_field_with_noclobber

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"]
开发者ID:cmshobe,项目名称:landlab,代码行数:13,代码来源:test_graph_fields.py


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