@@ -123,3 +123,51 @@ def test_ones():
123123 assert isinstance (a , blosc2 .NDArray )
124124 b = np .ones (shape , dtype = np .float32 )
125125 np .testing .assert_allclose (a [:], b )
126+
127+
128+ @pytest .mark .parametrize ("asarray" , [True , False ])
129+ @pytest .mark .parametrize ("typesize" , [255 , 256 , 257 , 261 , 256 * 256 ])
130+ @pytest .mark .parametrize ("shape" , [(1 ,), (3 ,), (10 ,), (1024 ,)])
131+ def test_large_typesize (shape , typesize , asarray ):
132+ dtype = np .dtype ([("f_001" , "<i1" , (typesize ,))])
133+ a = np .full (shape , 3 , dtype = dtype )
134+ if asarray :
135+ b = blosc2 .asarray (a )
136+ else :
137+ b = blosc2 .full (shape , 3 , dtype = dtype )
138+ assert np .array_equal (b [0 ], a [0 ])
139+
140+
141+ def test_complex_datatype ():
142+ dtype = np .dtype (
143+ [
144+ ("f_001" , "<f4" , (164 ,)),
145+ ("f_002" , "<f4" , (11 ,)),
146+ ("f_003" , "<f4" , (154 ,)),
147+ ("f_004" , "<f4" , (870 ,)),
148+ ("f_005" , "<f4" , (1062 ,)),
149+ ("f_006" , "<f4" , (22 ,)),
150+ ("f_007" , "<f4" , (44 ,)),
151+ ("f_008" , "<f4" , (512 ,)),
152+ ("f_009" , "<f4" , (64 , 77 )),
153+ ("f_010" , "<f4" , (97 , 489 )),
154+ ("f_011" , "<f4" , (75 , 255 )),
155+ ("f_012" , "<f4" , (8 , 293 )),
156+ ("f_013" , "<f4" , (230 , 591 )),
157+ ("f_014" , "<f4" , (101 , 193 )),
158+ ("f_015" , "<f4" , (12 , 48 )),
159+ ("f_016" , "<f4" , (90 , 699 )),
160+ ("f_017" , "<f4" , (125 , 65 )),
161+ ("f_018" , "<f4" , (132 , 81 )),
162+ ("f_019" , "<f4" , (27 , 363 )),
163+ ("f_020" , "S1000" ),
164+ ("f_021" , "S1000" ),
165+ ]
166+ )
167+ a = np .zeros ((256 ,), dtype = dtype )
168+ cparams = blosc2 .CParams (codec = blosc2 .Codec .BLOSCLZ , clevel = 1 , nthreads = 3 )
169+ b = blosc2 .asarray (a , cparams = cparams , urlpath = "b.b2nd" , mode = "w" )
170+ # Iterate over the fields of the structured array and check that the data is the same
171+ for field in dtype .fields :
172+ assert np .array_equal (b [field ], a [field ])
173+ blosc2 .remove_urlpath ("b.b2nd" )
0 commit comments