def METHOD_NAME(req_attr, all_attr, names, data, keys):
    for i, attr in enumerate(names):
        keys[attr] = i
        req_attr[attr].set_data(data[i, :])
        try:
            req_attr[attr].init(all_attr[attr])
        except KeyError as err:
            raise ValueError(
                f"attribute '{attr}' requested by one of the components"
                f" but no initial values given"
            ) from err