Skip to content

Commit

Permalink
Attempting to make this behave on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
shinzlet committed Oct 9, 2024
1 parent a22bbdb commit 2d9e015
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions softcopy/packed_name.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pathlib import Path
from typing import Literal

Expand All @@ -22,9 +23,9 @@ class PackedName:

def __init__(self, name: str, files_nd: np.ndarray, dim_separator: Literal["/", "."], zarr_format: Literal[2, 3]):
if dim_separator == "/":
parts = name.split("/")
parts = name.split(os.sep)
else:
last_slash = name.rfind("/")
last_slash = name.rfind(os.sep)
parts = name[last_slash + 1 :].split(dim_separator)

require_c_prefix = zarr_format == 3
Expand Down Expand Up @@ -81,6 +82,8 @@ def path_from_index(
zarr_format: Literal[2, 3],
) -> Path:
chunk_index_nd = np.unravel_index(index, files_nd)

# We don't need to worry about using `/` here, because on Windows, `Path` will automatically convert `/` to `\`
prefixless_chunk_key = dim_separator.join(map(str, chunk_index_nd))

if zarr_format == 3:
Expand Down

0 comments on commit 2d9e015

Please sign in to comment.