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

Speedup dependencies dtypes #363

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions audb/core/define.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ class DependField:
}

DEPEND_FIELD_DTYPES = {
DependField.ARCHIVE: "string",
DependField.ARCHIVE: "object",
DependField.BIT_DEPTH: "int32",
DependField.CHANNELS: "int32",
DependField.CHECKSUM: "string",
DependField.CHECKSUM: "object",
DependField.DURATION: "float64",
DependField.FORMAT: "string",
DependField.FORMAT: "object",
DependField.REMOVED: "int32",
DependField.SAMPLING_RATE: "int32",
DependField.TYPE: "int32",
DependField.VERSION: "string",
DependField.VERSION: "object",
}


Expand Down
1 change: 0 additions & 1 deletion audb/core/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ def load(self, path: str):
na_filter=False,
dtype=dtype_mapping,
)
self._df.index = self._df.index.astype("string")

def removed(self, file: str) -> bool:
r"""Check if file is marked as removed.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmark-dependency-methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
df[column] = df[column].astype(dtype)
df.set_index("file", inplace=True)
df.index.name = None
df.index = df.index.astype("string")
df.index = df.index.astype("object")
df.to_pickle(data_cache)

# === Create dependency object ===
Expand Down
2 changes: 0 additions & 2 deletions tests/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def deps():
df = pd.DataFrame.from_records(ROWS)
df.set_index("file", inplace=True)
# Ensure correct dtype
df.index = df.index.astype("string")
for name, dtype in zip(
audb.core.define.DEPEND_FIELD_NAMES.values(),
audb.core.define.DEPEND_FIELD_DTYPES.values(),
Expand Down Expand Up @@ -82,7 +81,6 @@ 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("string")
for name, dtype in zip(
audb.core.define.DEPEND_FIELD_NAMES.values(),
audb.core.define.DEPEND_FIELD_DTYPES.values(),
Expand Down
Loading