22
33import contextlib
44import pickle
5- import warnings
65from typing import TYPE_CHECKING , Any
76
87import numpy as np
1817from zarr import config , create_array , open_array
1918from zarr .abc .numcodec import _is_numcodec , _is_numcodec_cls
2019from zarr .codecs import numcodecs as _numcodecs
21- from zarr .errors import ZarrUserWarning
2220from zarr .registry import get_codec_class , get_numcodec
2321
2422if TYPE_CHECKING :
@@ -77,8 +75,6 @@ def test_is_numcodec_cls() -> None:
7775 assert _is_numcodec_cls (GZip )
7876
7977
80- EXPECTED_WARNING_STR = "Numcodecs codecs are not in the Zarr version 3.*"
81-
8278ALL_CODECS = tuple (
8379 filter (
8480 lambda v : issubclass (v , _numcodecs ._NumcodecsCodec ) and hasattr (v , "codec_name" ),
@@ -116,15 +112,14 @@ def test_docstring(codec_class: type[_numcodecs._NumcodecsCodec]) -> None:
116112def test_generic_compressor (codec_class : type [_numcodecs ._NumcodecsBytesBytesCodec ]) -> None :
117113 data = np .arange (0 , 256 , dtype = "uint16" ).reshape ((16 , 16 ))
118114
119- with pytest .warns (ZarrUserWarning , match = EXPECTED_WARNING_STR ):
120- a = create_array (
121- {},
122- shape = data .shape ,
123- chunks = (16 , 16 ),
124- dtype = data .dtype ,
125- fill_value = 0 ,
126- compressors = [codec_class ()],
127- )
115+ a = create_array (
116+ {},
117+ shape = data .shape ,
118+ chunks = (16 , 16 ),
119+ dtype = data .dtype ,
120+ fill_value = 0 ,
121+ compressors = [codec_class ()],
122+ )
128123
129124 a [:, :] = data .copy ()
130125 np .testing .assert_array_equal (data , a [:, :])
@@ -151,17 +146,16 @@ def test_generic_filter(
151146) -> None :
152147 data = np .linspace (0 , 10 , 256 , dtype = "float32" ).reshape ((16 , 16 ))
153148
154- with pytest .warns (ZarrUserWarning , match = EXPECTED_WARNING_STR ):
155- a = create_array (
156- {},
157- shape = data .shape ,
158- chunks = (16 , 16 ),
159- dtype = data .dtype ,
160- fill_value = 0 ,
161- filters = [
162- codec_class (** codec_config ),
163- ],
164- )
149+ a = create_array (
150+ {},
151+ shape = data .shape ,
152+ chunks = (16 , 16 ),
153+ dtype = data .dtype ,
154+ fill_value = 0 ,
155+ filters = [
156+ codec_class (** codec_config ),
157+ ],
158+ )
165159
166160 a [:, :] = data .copy ()
167161 with codec_conf ():
@@ -172,15 +166,14 @@ def test_generic_filter(
172166def test_generic_filter_bitround () -> None :
173167 data = np .linspace (0 , 1 , 256 , dtype = "float32" ).reshape ((16 , 16 ))
174168
175- with pytest .warns (ZarrUserWarning , match = EXPECTED_WARNING_STR ):
176- a = create_array (
177- {},
178- shape = data .shape ,
179- chunks = (16 , 16 ),
180- dtype = data .dtype ,
181- fill_value = 0 ,
182- filters = [_numcodecs .BitRound (keepbits = 3 )],
183- )
169+ a = create_array (
170+ {},
171+ shape = data .shape ,
172+ chunks = (16 , 16 ),
173+ dtype = data .dtype ,
174+ fill_value = 0 ,
175+ filters = [_numcodecs .BitRound (keepbits = 3 )],
176+ )
184177
185178 a [:, :] = data .copy ()
186179 b = open_array (a .store , mode = "r" )
@@ -190,15 +183,14 @@ def test_generic_filter_bitround() -> None:
190183def test_generic_filter_quantize () -> None :
191184 data = np .linspace (0 , 10 , 256 , dtype = "float32" ).reshape ((16 , 16 ))
192185
193- with pytest .warns (ZarrUserWarning , match = EXPECTED_WARNING_STR ):
194- a = create_array (
195- {},
196- shape = data .shape ,
197- chunks = (16 , 16 ),
198- dtype = data .dtype ,
199- fill_value = 0 ,
200- filters = [_numcodecs .Quantize (digits = 3 )],
201- )
186+ a = create_array (
187+ {},
188+ shape = data .shape ,
189+ chunks = (16 , 16 ),
190+ dtype = data .dtype ,
191+ fill_value = 0 ,
192+ filters = [_numcodecs .Quantize (digits = 3 )],
193+ )
202194
203195 a [:, :] = data .copy ()
204196 b = open_array (a .store , mode = "r" )
@@ -209,15 +201,14 @@ def test_generic_filter_packbits() -> None:
209201 data = np .zeros ((16 , 16 ), dtype = "bool" )
210202 data [0 :4 , :] = True
211203
212- with pytest .warns (ZarrUserWarning , match = EXPECTED_WARNING_STR ):
213- a = create_array (
214- {},
215- shape = data .shape ,
216- chunks = (16 , 16 ),
217- dtype = data .dtype ,
218- fill_value = 0 ,
219- filters = [_numcodecs .PackBits ()],
220- )
204+ a = create_array (
205+ {},
206+ shape = data .shape ,
207+ chunks = (16 , 16 ),
208+ dtype = data .dtype ,
209+ fill_value = 0 ,
210+ filters = [_numcodecs .PackBits ()],
211+ )
221212
222213 a [:, :] = data .copy ()
223214 b = open_array (a .store , mode = "r" )
@@ -253,15 +244,14 @@ def test_generic_checksum(codec_class: type[_numcodecs._NumcodecsBytesBytesCodec
253244
254245 data = np .linspace (0 , 10 , 256 , dtype = "float32" ).reshape ((16 , 16 ))
255246
256- with pytest .warns (ZarrUserWarning , match = EXPECTED_WARNING_STR ):
257- a = create_array (
258- {},
259- shape = data .shape ,
260- chunks = (16 , 16 ),
261- dtype = data .dtype ,
262- fill_value = 0 ,
263- compressors = [codec_class ()],
264- )
247+ a = create_array (
248+ {},
249+ shape = data .shape ,
250+ chunks = (16 , 16 ),
251+ dtype = data .dtype ,
252+ fill_value = 0 ,
253+ compressors = [codec_class ()],
254+ )
265255
266256 a [:, :] = data .copy ()
267257 with codec_conf ():
@@ -283,15 +273,14 @@ def test_generic_bytes_codec(codec_class: type[_numcodecs._NumcodecsArrayBytesCo
283273
284274 data = np .arange (0 , 256 , dtype = "float32" ).reshape ((16 , 16 ))
285275
286- with pytest .warns (ZarrUserWarning , match = EXPECTED_WARNING_STR ):
287- a = create_array (
288- {},
289- shape = data .shape ,
290- chunks = (16 , 16 ),
291- dtype = data .dtype ,
292- fill_value = 0 ,
293- serializer = codec_class (),
294- )
276+ a = create_array (
277+ {},
278+ shape = data .shape ,
279+ chunks = (16 , 16 ),
280+ dtype = data .dtype ,
281+ fill_value = 0 ,
282+ serializer = codec_class (),
283+ )
295284
296285 a [:, :] = data .copy ()
297286 np .testing .assert_array_equal (data , a [:, :])
@@ -300,17 +289,16 @@ def test_generic_bytes_codec(codec_class: type[_numcodecs._NumcodecsArrayBytesCo
300289def test_delta_astype () -> None :
301290 data = np .linspace (0 , 10 , 256 , dtype = "i8" ).reshape ((16 , 16 ))
302291
303- with pytest .warns (ZarrUserWarning , match = EXPECTED_WARNING_STR ):
304- a = create_array (
305- {},
306- shape = data .shape ,
307- chunks = (16 , 16 ),
308- dtype = data .dtype ,
309- fill_value = 0 ,
310- filters = [
311- _numcodecs .Delta (dtype = "i8" , astype = "i2" ),
312- ],
313- )
292+ a = create_array (
293+ {},
294+ shape = data .shape ,
295+ chunks = (16 , 16 ),
296+ dtype = data .dtype ,
297+ fill_value = 0 ,
298+ filters = [
299+ _numcodecs .Delta (dtype = "i8" , astype = "i2" ),
300+ ],
301+ )
314302
315303 a [:, :] = data .copy ()
316304 with codec_conf ():
@@ -325,36 +313,7 @@ def test_repr() -> None:
325313
326314def test_to_dict () -> None :
327315 codec = _numcodecs .LZ4 (level = 5 )
328- with pytest .warns (ZarrUserWarning , match = EXPECTED_WARNING_STR ):
329- assert codec .to_dict () == {"name" : "numcodecs.lz4" , "configuration" : {"level" : 5 }}
330-
331-
332- def test_warn_on_write_not_read () -> None :
333- data = np .arange (0 , 256 , dtype = "uint16" ).reshape ((16 , 16 ))
334-
335- with pytest .warns (ZarrUserWarning , match = EXPECTED_WARNING_STR ):
336- a = create_array (
337- {},
338- shape = data .shape ,
339- chunks = (16 , 16 ),
340- dtype = data .dtype ,
341- fill_value = 0 ,
342- compressors = [_numcodecs .Zstd (level = 1 )],
343- )
344-
345- a [:, :] = data .copy ()
346- with codec_conf ():
347- with warnings .catch_warnings (record = True ) as caught :
348- warnings .simplefilter ("always" )
349- b = open_array (a .store , mode = "r" )
350-
351- np .testing .assert_array_equal (data , b [:, :])
352- assert not [
353- warning
354- for warning in caught
355- if issubclass (warning .category , ZarrUserWarning )
356- and "Numcodecs codecs are not in the Zarr version 3 specification" in str (warning .message )
357- ]
316+ assert codec .to_dict () == {"name" : "numcodecs.lz4" , "configuration" : {"level" : 5 }}
358317
359318
360319@pytest .mark .parametrize (
0 commit comments