Skip to content

Commit

Permalink
fix if processing function returns empty table
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilian Schmitt committed May 7, 2024
1 parent 2980bc3 commit 79b4833
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions audinterface/core/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,18 +582,21 @@ def process_table(
ends.extend(index.get_level_values("end") + start)
labels.extend([[table.iloc[j].values] * len(index)])
labels = np.vstack(labels)
df_empty = False
if labels.shape == (1, 0):
labels = labels.squeeze()
df_empty = True

index = audformat.segmented_index(files, starts, ends)

if isinstance(table, pd.Series):
table = pd.Series(labels, index, name=table.name, dtype=dtype)
else:
labels = {
col: labels[:, icol].astype(dtypes[icol])
for icol, col in enumerate(table.columns)
}
if not df_empty:
labels = {
col: labels[:, icol].astype(dtypes[icol])
for icol, col in enumerate(table.columns)
}
table = pd.DataFrame(labels, index)

return table
Expand Down

0 comments on commit 79b4833

Please sign in to comment.