# Buggy code
def _get_max_shape(self, shape, max_shape):
    if max_shape is None:
        return tuple([s or self._int32max for s in shape])
    elif isinstance(max_shape, int):
        assert max_shape == shape[0]
        return self._get_max_shape(shape, None)
    else:
        max_shape = tuple(max_shape)
        assert len(shape) == len(max_shape)
        for s, ms in zip(shape, max_shape):
            assert s == ms or s is None and isinstance(ms, int)
        return max_shape


# Traceback (AssertionError)
➜  feature_testing python upload_animals.py
26180
{'labels': ClassLabel(shape=(), dtype='int64', names=['pecora', 'mucca', 'cane', 'ragno', 'cavallo', 'elefante', 'gallina', 'gatto', 'scoiattolo', 'farfalla'], num_classes=10), 'image': Image(shape=(120, 120, 3), dtype='uint8', max_shape=(120, 120, 4))}
ClassLabel(shape=(), dtype='int64', names=['pecora', 'mucca', 'cane', 'ragno', 'cavallo', 'elefante', 'gallina', 'gatto', 'scoiattolo', 'farfalla'], num_classes=10)
Deleting the dataset Traceback (most recent call last):
File "/home/debo/Hub/hub/api/dataset.py", line 154, in __init__
self._tensors = dict(self._generate_storage_tensors())
File "/home/debo/Hub/hub/api/dataset.py", line 249, in _generate_storage_tensors
yield t_path, DynamicTensor(
File "/home/debo/Hub/hub/store/dynamic_tensor.py", line 67, in __init__
shapeDt = ShapeDetector(shape, max_shape, chunks, dtype)
File "/home/debo/Hub/hub/store/shape_detector.py", line 27, in __init__
self._max_shape = max_shape = self._get_max_shape(shape, max_shape)
File "/home/debo/Hub/hub/store/shape_detector.py", line 50, in _get_max_shape
assert s == ms or s is None and isinstance(ms, int)
AssertionError

Traceback (most recent call last):
File "upload_animals.py", line 23, in <module>
ds,labels = Dataset.from_directory(url,root_folder,image_shape,(ds_size,),'w+',max_shape=(120,120,4))
File "/home/debo/Hub/hub/api/dataset.py", line 680, in from_directory
ds = Dataset(
File "/home/debo/Hub/hub/api/dataset.py", line 154, in __init__
self._tensors = dict(self._generate_storage_tensors())
File "/home/debo/Hub/hub/api/dataset.py", line 249, in _generate_storage_tensors
yield t_path, DynamicTensor(
File "/home/debo/Hub/hub/store/dynamic_tensor.py", line 67, in __init__
shapeDt = ShapeDetector(shape, max_shape, chunks, dtype)
File "/home/debo/Hub/hub/store/shape_detector.py", line 27, in __init__
self._max_shape = max_shape = self._get_max_shape(shape, max_shape)
File "/home/debo/Hub/hub/store/shape_detector.py", line 50, in _get_max_shape
assert s == ms or s is None and isinstance(ms, int)
AssertionError

# Fixed code
def _get_max_shape(self, shape, max_shape):
    if max_shape is None:
        return tuple([s or self._int32max for s in shape])
    elif isinstance(max_shape, int):
        assert max_shape == shape[0]
        return self._get_max_shape(shape, None)
    else:
        max_shape = tuple(max_shape)
        assert len(shape) == len(max_shape)
        for s, ms in zip(shape, max_shape):
            if not isinstance(ms, int):
                raise HubException("MaxShape Dimension should be int")
            if s is not None and s != ms:
                raise HubException(
                    """Dimension in shape cannot be != max_shape dimension, 
                        if shape is not None """
                )
            assert s == ms or s is None and isinstance(ms, int)
        return max_shape