-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add audformat.utils.join_labels() #66
Conversation
Puhh, good you pushed this early, a minute ago I started to work on the same issue :) Glad to only have to review this one :) |
Codecov Report
|
Currently the following is possible: labels_1 = {
0: {'age': 20},
}
labels_2 = {
'0': {'age': 30},
}
labels = audformat.utils.join_labels([labels_1, labels_2])
print(labels)
So I wonder if we should check for same key type when we merge dictionaries? An easy way to do so is trying to create a audformat.Scheme(labels=labels)
|
Currently, it's not possible to update dictionaries with new values: labels_1 = {
0: {'age': 20},
}
labels_2 = {
0: {'gender': 'male'},
}
labels = audformat.utils.join_labels([labels_1, labels_2])
print(labels)
It would be nice if we get:
|
Good point, I now allow for overwriting and updated the documentation screenshot in the description. |
Co-authored-by: Johannes Wagner <[email protected]>
I agree, will update the code accordingly. |
Implemented it: >>> audformat.utils.join_labels([{0: {'age': 20}}, {'0': {'age': 30}}])
...
ValueError: All labels must be of the same data type. also added a test for it. |
As discussed in #66 (review) this adds
audformat.utils.join_labels()
as a helper function to join scheme labels before merging two databases.