-
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 method to drop scheme from database #299
Comments
@hagenw what is your take here? Since we also don't have methods to drop media, raters, attachments etc. I wonder if we should simply close the issue as I don't see us implementing all those methods at the moment. |
I'm not completely sure if we can argue that we also don't have drop methods for media, raters, attachments as we have But I think it is not very urgent as you can delete a scheme with import audformat
db = audformat.Database('db')
db.schemes['spk'] = audformat.Scheme('str', labels=['a', 'b'])
index = audformat.filewise_index(['f1', 'f2'])
db['files'] = audformat.Table(index)
db['files']['spk'] = audformat.Column(scheme_id='spk')
db['files']['spk'].set(['a', 'a'])
db.schemes['label'] = audformat.Scheme('int')
index = audformat.segmented_index(['f1', 'f1'], [0, 1], [1, 2])
db['segments'] = audformat.Table(index)
db['segments']['spk'] = audformat.Column(scheme_id='spk')
db['segments']['spk'].set(['a', 'a']) and then >>> del db.schemes['spk']
>>> db
name: db
source: ''
usage: unrestricted
languages: []
schemes:
label: {dtype: int}
tables:
files:
type: filewise
columns:
spk: {scheme_id: spk}
segments:
type: segmented
columns:
spk: {scheme_id: spk}
>>> db.save('test-db')
>>> db = audformat.Database.load('test-db')
>>> db
name: db
source: ''
usage: unrestricted
languages: []
schemes:
label: {dtype: int}
tables:
files:
type: filewise
columns:
spk: {scheme_id: spk}
segments:
type: segmented
columns:
spk: {scheme_id: spk} The only not so nice think is the error message you are getting at the moment when the deleted scheme is needed: >>> df = db['files'].get()
...
BadKeyError: "Bad key 'spk', expected one of ['label']"
>>> df = db['segments'].get()
...
BadKeyError: "Bad key 'spk', expected one of ['label']"
|
To avoid that a user removes a scheme that is used in a table, it could make sense to introduce
Database.drop_scheme()
to raise an error in that case.The text was updated successfully, but these errors were encountered: