Skip to content
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 get index per split and table type of all tables #200

Open
hagenw opened this issue Jun 23, 2022 · 4 comments
Open

Add method to get index per split and table type of all tables #200

hagenw opened this issue Jun 23, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@hagenw
Copy link
Member

hagenw commented Jun 23, 2022

A user might be interested to get the index for all files or segments included in one split.

To get all segments involved in the a split called test you would need to do the following at the moment:

split = 'test'
type = 'segmented'
tables = [t for t in db.tables if db[t].split_id == split]
tables = [t for t in tables if audformat.index_type(db[t].index) == type]
index = audformat.utils.union([db[t].index for t in tables])

We could make this easier by converting the property audformat.Database.index into a method:

index = db.index(split='test', index_type='segmented')

The only problem is that Database.index is a property and we would break the API if we convert it to a method.
If we don't find a way to achieve this, we should maybe not target it or use another name (e.g. filter_index) for the proposed method.

/cc @phtephanx

@hagenw hagenw added the enhancement New feature or request label Jun 23, 2022
@hagenw hagenw changed the title Convert audfromat.Database.index to a method Add method to get index per split and table type of all tables Jun 23, 2022
@frankenjoe
Copy link
Collaborator

Maybe introduce a method db.index_by_split()?

@hagenw
Copy link
Member Author

hagenw commented Jun 23, 2022

This would be a solution. I'm not completely sure if we should limit the functionality already in the name, as you can in principle filter after split, media (as in audformat.Media), index type, but split is most likely the most important attribute.

@frankenjoe
Copy link
Collaborator

The only problem is that Database.index is a property and we would break the API

Actually, I just realized that we do not have a property Database.index yet, neither an attribute or method.

@hagenw
Copy link
Member Author

hagenw commented Jul 4, 2022

You are right, we only have it for the single tables. So it should be straightforward to solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants