Praveen Kulkarni commited on
Commit
007682c
·
1 Parent(s): 93fe4fb

utf8 encoding

Browse files
Files changed (1) hide show
  1. test.py +32 -1
test.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import zarr
2
  import numpy as np
3
  import datasets
@@ -55,6 +57,34 @@ class ZarrTest:
55
  store1.close()
56
  store2.close()
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  @staticmethod
59
  def create_in_zip():
60
  store1 = zarr.ZipStore('data.zarr.zip')
@@ -110,7 +140,8 @@ class ZarrTest:
110
 
111
  # ZarrTest.create()
112
  # ZarrTest.create_in_zip()
113
- ZarrTest.load_from_hf()
 
114
 
115
  class Test(datasets.GeneratorBasedBuilder):
116
  VERSION = datasets.Version("1.0.0")
 
1
+ import huggingface_hub
2
+ import requests.exceptions
3
  import zarr
4
  import numpy as np
5
  import datasets
 
57
  store1.close()
58
  store2.close()
59
 
60
+ @staticmethod
61
+ def create_in_hf():
62
+ try:
63
+ huggingface_hub.delete_folder(path_in_repo="data.zarr", repo_id="spikingneurons/test", repo_type="dataset")
64
+ except requests.exceptions.HTTPError as e:
65
+ ...
66
+ store1 = zarr.DirectoryStore('hf://datasets/spikingneurons/test/data.zarr')
67
+ root1 = zarr.group(store=store1)
68
+ z1 = root1.zeros('trace', shape=(100, 100), chunks=(100, 10), dtype='i1', overwrite=True)
69
+ z1[:] = 42
70
+ z1[0, :] = np.arange(100)
71
+ z1[:, 0] = np.arange(100)
72
+ z2 = root1.zeros('plaintext', shape=100, dtype='u1', overwrite=True)
73
+ z3 = root1.zeros('ciphertext', shape=100, dtype='u1', overwrite=True)
74
+ z4 = root1.zeros('key', shape=100, dtype='u1', overwrite=True)
75
+ z2[:] = 22
76
+ z3[:] = 33
77
+ z4[:] = 44
78
+ zarr.consolidate_metadata(store1)
79
+ print(z1[:])
80
+ store1.close()
81
+
82
+
83
+ store2 = zarr.DirectoryStore('hf://datasets/spikingneurons/test/data.zarr')
84
+ root2 = zarr.open_consolidated(store2)
85
+ print(root2['trace'][:])
86
+ store2.close()
87
+
88
  @staticmethod
89
  def create_in_zip():
90
  store1 = zarr.ZipStore('data.zarr.zip')
 
140
 
141
  # ZarrTest.create()
142
  # ZarrTest.create_in_zip()
143
+ # ZarrTest.load_from_hf()
144
+ ZarrTest.create_in_hf()
145
 
146
  class Test(datasets.GeneratorBasedBuilder):
147
  VERSION = datasets.Version("1.0.0")