Visitar URL original
Harden path-handling after pathlib migration by deruyter92 · Pull Request #3421 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
hardening of path-normalization in guarantee_multiindex_rows
The old code checks only the first row (df.index[0]) to decide whether to split on / or \, then applies that one separator to the entire DataFrame.

The new approach normalizes all backslashes to forward slashes first, then splits. So mixed-separator DataFrames (e.g. cross platform merges) work correctly.
  • Loading branch information
deruyter92 committed Jul 21, 2026
commit 7667748fea88edfb4ae1c8a4a6ba8a8070d55111
6 changes: 2 additions & 4 deletions deeplabcut/utils/conversioncode.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,9 @@ def merge_windowsannotationdataONlinuxsystem(cfg):
def guarantee_multiindex_rows(df):
# Make paths platform-agnostic if they are not already
if not isinstance(df.index, pd.MultiIndex): # Backwards compatibility
path = df.index[0]
try:
sep = "/" if "/" in path else "\\"
splits = tuple(df.index.str.split(sep))
df.index = pd.MultiIndex.from_tuples(splits)
splits = df.index.str.replace("\\", "/").str.split("/")
df.index = pd.MultiIndex.from_tuples([tuple(s) for s in splits])
except TypeError: # Ignore numerical index of frame indices
pass

Expand Down