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

Empty misc table can lead to errors #432

Open
hagenw opened this issue Jun 11, 2024 · 0 comments
Open

Empty misc table can lead to errors #432

hagenw opened this issue Jun 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@hagenw
Copy link
Member

hagenw commented Jun 11, 2024

One can initialize a misc table with None as index:

>>> import audformat
>>> table = audformat.MiscTable(None)

But this let's some of its method fail:

>>> table.copy()
...
ValueError: Got index with levels [None], but names must be non-empty and unique.

>>> table.extend_index(pd.Index([0, 1, 2], name="idx"))
...
ValueError: Got index with levels [None], but names must be non-empty and unique.

>>> table.extend_index(pd.Index([0, 1, 2], name="idx"), inplace=True)
ValueError: Cannot extend table if input index and table index are not alike.
Expected index:
        idx    int64
but yours is:
        None    int64

You can extend the table with:

>>> table.extend_index(pd.Index([0, 1, 2]), inplace=True)
>>> table.index
Index([0, 1, 2], dtype='Int64')

But now you have created a table without a name for the index and empty levels:

>>> table.levels

If you would have tried this when creating the table, it would have failed with

>>> table = audformat.MiscTable(pd.Index([0, 1, 2]))
...
ValueError: Got index with levels [None], but names must be non-empty and unique.
@hagenw hagenw added the bug Something isn't working label Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant