nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: seung-lab/cloud-volume
Pull request #399 (2020-09-09 20:44:05)

fix(windows,paths): non-file windows parsing was broken
Windows parsing was dropping the bucket name from the path.


Patch:
diff --git a/cloudvolume/frontends/graphene.py b/cloudvolume/frontends/graphene.py
index b0099ea..5b6de8a 100644
--- a/cloudvolume/frontends/graphene.py
+++ b/cloudvolume/frontends/graphene.py
@@ -32,6 +32,9 @@ def to_unix_time(timestamp):
   and Python datetime objects and returns them as the equivalent
   UNIX timestamp or None if timestamp is None.
   """
+  if timestamp is None:
+    return None
+
   if isinstance(timestamp, str):
     timestamp = dateutil.parser.parse(timestamp) # returns datetime
   if isinstance(timestamp, datetime): # NB. do not change to elif
diff --git a/cloudvolume/paths.py b/cloudvolume/paths.py
index aca35d9..52f9084 100644
--- a/cloudvolume/paths.py
+++ b/cloudvolume/paths.py
@@ -159,7 +159,7 @@ def extract(cloudpath, windows=None, disable_toabs=False):
     no_bucket_basepath = split_char.join(splitties[1:-1])
   elif len(splitties) >= 2:
     dataset, layer = splitties[-2:]
-    if windows:
+    if windows and protocol == 'file':
       no_bucket_basepath = split_char.join(splitties[2:-1])
       basepath = split_char.join([bucket] + splitties[2:-1])
     else:


Test patch:
diff --git a/test/test_paths.py b/test/test_paths.py
index 96ede67..397b436 100644
--- a/test/test_paths.py
+++ b/test/test_paths.py
@@ -145,4 +145,13 @@ def test_windows_path_extraction():
   assert extract.basepath == 'C:\\wow\\this\\is\\a\\cool'
   assert extract.no_bucket_basepath == 'this\\is\\a\\cool'  
   assert extract.dataset == 'cool'  
-  assert extract.layer == 'path'  
\ No newline at end of file
+  assert extract.layer == 'path'  
+
+  extract = paths.extract('precomputed://https://storage.googleapis.com/neuroglancer-public-data/kasthuri2011/ground_truth', windows=True)
+  assert extract.format == 'precomputed'
+  assert extract.protocol == 'https'
+  assert extract.bucket == 'storage.googleapis.com'
+  assert extract.basepath == 'storage.googleapis.com/neuroglancer-public-data/kasthuri2011'
+  assert extract.no_bucket_basepath == 'neuroglancer-public-data/kasthuri2011'  
+  assert extract.dataset == 'kasthuri2011'  
+  assert extract.layer == 'ground_truth'
Repository: seung-lab/cloud-volume
Pull request #445 (2021-02-09 18:55:42)

fix(encode_jpeg): correct 3D->2D shape for Neuroglancer
Array shape mixup in between the transposing / axis swapping / reshaping transformations.
Happened during the switch to simple_jpeg (#392)

william-silversmith: Can you confirm with a visual inspection of a new upload? The code already there is likely correct as that's how I did it.

Patch:
diff --git a/cloudvolume/chunks.py b/cloudvolume/chunks.py
index 5102cc8..637e0e7 100644
--- a/cloudvolume/chunks.py
+++ b/cloudvolume/chunks.py
@@ -94,7 +94,7 @@ def encode_jpeg(arr, quality=85):
   reshaped = arr.T
   reshaped = np.moveaxis(reshaped, 0, -1)
   reshaped = reshaped.reshape(
-    arr.shape[0] * arr.shape[1], arr.shape[2], num_channel
+    reshaped.shape[0] * reshaped.shape[1], reshaped.shape[2], num_channel
   )
   if num_channel == 1:
     return simplejpeg.encode_jpeg(


Test patch:
diff --git a/test/test_chunks.py b/test/test_chunks.py
index 260b31c..bbb3655 100644
--- a/test/test_chunks.py
+++ b/test/test_chunks.py
@@ -97,14 +97,23 @@ def test_npz():
   random_data = np.random.randint(255, size=(64,64,64,1), dtype=np.uint8)
   encode_decode(random_data, 'npz')
 
-@pytest.mark.parametrize("shape", ( (64,64,64), (64,61,50)))
+@pytest.mark.parametrize("shape", ( (64,64,64), (64,61,50), (128,128,16), ))
 @pytest.mark.parametrize("num_channels", (1,3))
 def test_jpeg(shape, num_channels):
+  import simplejpeg
+
   xshape = list(shape) + [ num_channels ]
   data = np.zeros(shape=xshape, dtype=np.uint8)
   encode_decode(data, 'jpeg', shape, num_channels)
   encode_decode(data + 255, 'jpeg', shape, num_channels)
 
+  jpg = simplejpeg.decode_jpeg(
+    encode(data, 'jpeg'), 
+    colorspace="GRAY",
+  )
+  assert jpg.shape[0] == shape[1] * shape[2]
+  assert jpg.shape[1] == shape[0]
+
   # Random jpeg won't decompress to exactly the same image
   # but it should have nearly the same average power
   random_data = np.random.randint(255, size=xshape, dtype=np.uint8)