Skip to content

Commit

Permalink
Ensure dependency table index has no name (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Feb 23, 2024
1 parent cc826a0 commit 44de33f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions audb/core/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def load(self, path: str):
na_filter=False,
dtype=dtype_mapping,
)
self._df.index.name = None
# Set dtype of index for both CSV and PKL
# to make backward compatiple
# with old pickle files in cache
Expand Down
3 changes: 2 additions & 1 deletion tests/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def deps():
df.set_index("file", inplace=True)
# Ensure correct dtype
df.index = df.index.astype(audb.core.define.DEPEND_INDEX_DTYPE)
df.index.name = None
for name, dtype in zip(
audb.core.define.DEPEND_FIELD_NAMES.values(),
audb.core.define.DEPEND_FIELD_DTYPES.values(),
Expand Down Expand Up @@ -75,6 +76,7 @@ def test_init(deps):
def test_call(deps):
expected_df = pd.DataFrame.from_records(ROWS).set_index("file")
expected_df.index = expected_df.index.astype(audb.core.define.DEPEND_INDEX_DTYPE)
expected_df.index.name = None
for name, dtype in zip(
audb.core.define.DEPEND_FIELD_NAMES.values(),
audb.core.define.DEPEND_FIELD_DTYPES.values(),
Expand Down Expand Up @@ -235,7 +237,6 @@ def test_len(deps):
def test_str(deps):
expected_str = (
" archive bit_depth channels ... sampling_rate type version\n" # noqa: E501
"file ... \n" # noqa: E501
"db.files.csv archive1 0 0 ... 0 0 1.0.0\n" # noqa: E501
"file.wav archive2 16 2 ... 16000 1 1.0.0\n" # noqa: E501
"\n"
Expand Down

0 comments on commit 44de33f

Please sign in to comment.