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):
109
109
GLOBAL_REGISTERED_CODECS_STOP ,
110
110
MAX_BLOCKSIZE ,
111
111
MAX_BUFFERSIZE ,
112
+ MAX_DIM ,
112
113
MAX_OVERHEAD ,
113
114
MAX_TYPESIZE ,
114
115
MIN_HEADER_LENGTH ,
Original file line number Diff line number Diff line change @@ -542,6 +542,7 @@ MAX_TYPESIZE = BLOSC2_MAXTYPESIZE
542
542
MAX_BUFFERSIZE = BLOSC2_MAX_BUFFERSIZE
543
543
MAX_BLOCKSIZE = BLOSC2_MAXBLOCKSIZE
544
544
MAX_OVERHEAD = BLOSC2_MAX_OVERHEAD
545
+ MAX_DIM = B2ND_MAX_DIM
545
546
VERSION_STRING = (< char * > BLOSC2_VERSION_STRING).decode(" utf-8" )
546
547
VERSION_DATE = (< char * > BLOSC2_VERSION_DATE).decode(" utf-8" )
547
548
MIN_HEADER_LENGTH = BLOSC_MIN_HEADER_LENGTH
Original file line number Diff line number Diff line change @@ -2914,6 +2914,8 @@ def _check_shape(shape):
2914
2914
shape = (shape ,)
2915
2915
elif not isinstance (shape , tuple | list ):
2916
2916
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 } )!" )
2917
2919
return shape
2918
2920
2919
2921
Original file line number Diff line number Diff line change @@ -166,3 +166,9 @@ def test_shape_empty():
166
166
assert a .dtype == np .int32
167
167
b = np .zeros ((), dtype = np .int32 )
168
168
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