@@ -40,8 +40,7 @@ def to_dict(self) -> dict[str, JSON]:
4040 def evolve_from_array_spec (self , array_spec : ArraySpec ) -> Self :
4141 return self
4242
43- # TODO: expand the tests for this function
44- async def _decode_single (
43+ def _decode_sync (
4544 self ,
4645 chunk_bytes : Buffer ,
4746 chunk_spec : ArraySpec ,
@@ -55,7 +54,14 @@ async def _decode_single(
5554 as_string_dtype = decoded .astype (chunk_spec .dtype .to_native_dtype (), copy = False )
5655 return chunk_spec .prototype .nd_buffer .from_numpy_array (as_string_dtype )
5756
58- async def _encode_single (
57+ async def _decode_single (
58+ self ,
59+ chunk_bytes : Buffer ,
60+ chunk_spec : ArraySpec ,
61+ ) -> NDBuffer :
62+ return self ._decode_sync (chunk_bytes , chunk_spec )
63+
64+ def _encode_sync (
5965 self ,
6066 chunk_array : NDBuffer ,
6167 chunk_spec : ArraySpec ,
@@ -65,6 +71,13 @@ async def _encode_single(
6571 _vlen_utf8_codec .encode (chunk_array .as_numpy_array ())
6672 )
6773
74+ async def _encode_single (
75+ self ,
76+ chunk_array : NDBuffer ,
77+ chunk_spec : ArraySpec ,
78+ ) -> Buffer | None :
79+ return self ._encode_sync (chunk_array , chunk_spec )
80+
6881 def compute_encoded_size (self , input_byte_length : int , _chunk_spec : ArraySpec ) -> int :
6982 # what is input_byte_length for an object dtype?
7083 raise NotImplementedError ("compute_encoded_size is not implemented for VLen codecs" )
@@ -86,7 +99,7 @@ def to_dict(self) -> dict[str, JSON]:
8699 def evolve_from_array_spec (self , array_spec : ArraySpec ) -> Self :
87100 return self
88101
89- async def _decode_single (
102+ def _decode_sync (
90103 self ,
91104 chunk_bytes : Buffer ,
92105 chunk_spec : ArraySpec ,
@@ -99,7 +112,14 @@ async def _decode_single(
99112 decoded = _reshape_view (decoded , chunk_spec .shape )
100113 return chunk_spec .prototype .nd_buffer .from_numpy_array (decoded )
101114
102- async def _encode_single (
115+ async def _decode_single (
116+ self ,
117+ chunk_bytes : Buffer ,
118+ chunk_spec : ArraySpec ,
119+ ) -> NDBuffer :
120+ return self ._decode_sync (chunk_bytes , chunk_spec )
121+
122+ def _encode_sync (
103123 self ,
104124 chunk_array : NDBuffer ,
105125 chunk_spec : ArraySpec ,
@@ -109,6 +129,13 @@ async def _encode_single(
109129 _vlen_bytes_codec .encode (chunk_array .as_numpy_array ())
110130 )
111131
132+ async def _encode_single (
133+ self ,
134+ chunk_array : NDBuffer ,
135+ chunk_spec : ArraySpec ,
136+ ) -> Buffer | None :
137+ return self ._encode_sync (chunk_array , chunk_spec )
138+
112139 def compute_encoded_size (self , input_byte_length : int , _chunk_spec : ArraySpec ) -> int :
113140 # what is input_byte_length for an object dtype?
114141 raise NotImplementedError ("compute_encoded_size is not implemented for VLen codecs" )
0 commit comments