File tree Expand file tree Collapse file tree 4 files changed +10
-0
lines changed
Expand file tree Collapse file tree 4 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ class Tuner(Enum):
109109 GLOBAL_REGISTERED_CODECS_STOP ,
110110 MAX_BLOCKSIZE ,
111111 MAX_BUFFERSIZE ,
112+ MAX_DIM ,
112113 MAX_OVERHEAD ,
113114 MAX_TYPESIZE ,
114115 MIN_HEADER_LENGTH ,
Original file line number Diff line number Diff line change @@ -542,6 +542,7 @@ MAX_TYPESIZE = BLOSC2_MAXTYPESIZE
542542MAX_BUFFERSIZE = BLOSC2_MAX_BUFFERSIZE
543543MAX_BLOCKSIZE = BLOSC2_MAXBLOCKSIZE
544544MAX_OVERHEAD = BLOSC2_MAX_OVERHEAD
545+ MAX_DIM = B2ND_MAX_DIM
545546VERSION_STRING = (< char * > BLOSC2_VERSION_STRING).decode(" utf-8" )
546547VERSION_DATE = (< char * > BLOSC2_VERSION_DATE).decode(" utf-8" )
547548MIN_HEADER_LENGTH = BLOSC_MIN_HEADER_LENGTH
Original file line number Diff line number Diff line change @@ -2914,6 +2914,8 @@ def _check_shape(shape):
29142914 shape = (shape ,)
29152915 elif not isinstance (shape , tuple | list ):
29162916 raise TypeError ("shape should be a tuple or a list!" )
2917+ if len (shape ) > blosc2 .MAX_DIM :
2918+ raise ValueError (f"shape length { len (shape )} is too large (>{ blosc2 .MAX_DIM } )!" )
29172919 return shape
29182920
29192921
Original file line number Diff line number Diff line change @@ -166,3 +166,9 @@ def test_shape_empty():
166166 assert a .dtype == np .int32
167167 b = np .zeros ((), dtype = np .int32 )
168168 np .testing .assert_equal (a [()], b )
169+
170+
171+ def test_shape_max_dims ():
172+ # Test that the shape cannot exceed the maximum number of dimensions
173+ with pytest .raises (ValueError ):
174+ a = blosc2 .zeros ((1 ,) * (blosc2 .MAX_DIM + 1 ), dtype = np .int32 )
You can’t perform that action at this time.
0 commit comments