From 2d9e015d3fc272053d39ea6947b4af3bb72c1db6 Mon Sep 17 00:00:00 2001 From: Seth Hinz Date: Wed, 9 Oct 2024 09:07:12 -0700 Subject: [PATCH] Attempting to make this behave on windows --- softcopy/packed_name.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/softcopy/packed_name.py b/softcopy/packed_name.py index 1dee888..11433eb 100644 --- a/softcopy/packed_name.py +++ b/softcopy/packed_name.py @@ -1,3 +1,4 @@ +import os from pathlib import Path from typing import Literal @@ -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 @@ -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: