コード例 #1
0
ファイル: test_graph_fields.py プロジェクト: pfeiffea/landlab
def test_setting_units(name, unit_str):
    fields = ModelDataFields()
    fields.new_field_location("node", 12)
    fields.add_field(name, np.empty(12), at="node", units=unit_str[::-1])
    assert fields.field_units("node", name) == unit_str[::-1]

    fields["node"].set_units(name, unit_str)
    assert fields.field_units("node", name) == unit_str
コード例 #2
0
ファイル: test_graph_fields.py プロジェクト: pfeiffea/landlab
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("vals", at="link")
    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"]
コード例 #3
0
ファイル: test_graph_fields.py プロジェクト: cmshobe/landlab
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"]
コード例 #4
0
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']
コード例 #5
0
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']
コード例 #6
0
ファイル: test_graph_fields.py プロジェクト: Carralex/landlab
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'])
コード例 #7
0
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'])