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