Ejemplo n.º 1
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'])
Ejemplo n.º 2
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"]
Ejemplo n.º 3
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']